Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » Characters displaying numbers
Characters displaying numbers [message #27917] Tue, 10 August 2010 20:56 Go to next message
nick28th is currently offline  nick28th
Messages: 13
Registered: August 2010
Location: Missouri
Promising Member
-Solved-

[Updated on: Sun, 15 August 2010 05:44]

Report message to a moderator

Re: Characters displaying numbers [message #27921 is a reply to message #27917] Tue, 10 August 2010 21:27 Go to previous messageGo to next message
nick28th is currently offline  nick28th
Messages: 13
Registered: August 2010
Location: Missouri
Promising Member
PLEASE, i cannot figure this out
Re: Characters displaying numbers [message #27926 is a reply to message #27917] Tue, 10 August 2010 23:23 Go to previous messageGo to next message
Sender Ghost is currently offline  Sender Ghost
Messages: 301
Registered: November 2008
Senior Member
Hello, Nick.

When you get data from ArrayCtrl you get it in Value type.
To convert it to integer type you can use ValueTo template:
const Value& v = array.Get(0, 0); // some data from ArrayCtrl
int i;
if (IsNumber(v)) // Check for Number format
  i = ValueTo<int>(v); // conversion
else PromptOK("Error input format");

Also you can use atoi or CParser ReadNumber functions.

Edit:
But if I understood you correctly, you just need to change your DNA5, DNA3, RNA5, RNA3 type from char to String.

[Updated on: Tue, 10 August 2010 23:36]

Report message to a moderator

Re: Characters displaying numbers [message #27928 is a reply to message #27926] Wed, 11 August 2010 06:26 Go to previous messageGo to next message
Mindtraveller is currently offline  Mindtraveller
Messages: 917
Registered: August 2007
Location: Russia, Moscow rgn.
Experienced Contributor

Hello, Sender Ghost!

Please avoid using ValueTo<> function.
For integer values it opens a hell of problems with int/int64 compatibility.
Please consider using
i = (int) v;
instead.
This is important thing, because with ValueTo<> you may have everything compiled well but meet a tons of run-time exceptions instead.
Re: Characters displaying numbers [message #27932 is a reply to message #27928] Wed, 11 August 2010 08:31 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello

Yes, I think just this is enough:

Value v, w;
int i;
String s;

...

i = v;
s = w;


Best regards
Iñaki
Re: Characters displaying numbers [message #27934 is a reply to message #27932] Wed, 11 August 2010 08:48 Go to previous messageGo to next message
Mindtraveller is currently offline  Mindtraveller
Messages: 917
Registered: August 2007
Location: Russia, Moscow rgn.
Experienced Contributor

Thanks, koldo! Your example is shorter and better. I just use explicit conversion for the sake of code readability.
Re: Characters displaying numbers [message #27937 is a reply to message #27934] Wed, 11 August 2010 10:22 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Smile

Best regards
Iñaki
Re: Characters displaying numbers [message #27947 is a reply to message #27928] Wed, 11 August 2010 19:17 Go to previous messageGo to next message
Sender Ghost is currently offline  Sender Ghost
Messages: 301
Registered: November 2008
Senior Member
Hello, Pavel.

Thanks, for tip. I read about your experience with such problems on the forum. Practically, it looks like the same (on the 312 line of uppsrc/Core/Value.h), but compiler can do something otherwise.

But, I guess, current problem is different.
char *DNA5 = "A"; or just using A with quotes to Add function is more appropriate.

[Updated on: Wed, 11 August 2010 19:18]

Report message to a moderator

Re: Characters displaying numbers [message #27989 is a reply to message #27947] Fri, 13 August 2010 00:16 Go to previous message
nick28th is currently offline  nick28th
Messages: 13
Registered: August 2010
Location: Missouri
Promising Member
nah i figured it out just did it (As string())
Previous Topic: Debugger’s Explorer tab & display of arrays/vectors
Next Topic: Demo time trial
Goto Forum:
  


Current Time: Fri Mar 29 15:08:19 CET 2024

Total time taken to generate the page: 0.02056 seconds