PDA

View Full Version : Question regarding num conversion


sdkfz250
10-04-2009, 12:32 PM
Hello,
maybe this is a stupid question.

If I want to have the last digit of a number (e.g. 123 i want to extract 3) if i work with the following code it does not work:

temp$=str(points$); //points$ is a number
G_SHOWMESSAGE(temp$[1,0]);

Why does this not work? With str() I converted the number in a string. temp[1,0] should allocate the last digit in a string beginning from the right side.

Thanks for your help in advance , Michael

Nicknack
10-04-2009, 04:54 PM
hi,
this somehow works:
temp$=str(points$); //points$ is a number
G_SHOWMESSAGE(wstr(temp$[1,0]));
and this combination also:
temp$=points$+""; //points$ is a number
G_SHOWMESSAGE(temp$[1,0]+"");
maybe kornalius can explain why a double conversion is needed.

sdkfz250
10-04-2009, 06:04 PM
Hey, you answered so quick. That's realy great.

Thanks for your help.

Michael

kornalius
10-04-2009, 07:58 PM
This is something I will have to look into. You can also try using the mid() function as a replacement in the meantime.

kornalius
10-11-2009, 08:23 PM
This works great in 2.2 and 1.60. I have fixed the str() function. If the value was 0, it did not create a string as "0" properly.