Ariane Soft PPL2 Pocket Programming DataMite
  #1  
Old 10-04-2009, 11:32 AM
sdkfz250 sdkfz250 is offline
Member
 
Join Date: Jul 2009
Posts: 36
Default Question regarding num conversion

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
Reply With Quote
  #2  
Old 10-04-2009, 03:54 PM
Nicknack Nicknack is offline
Senior Member
 
Join Date: Nov 2006
Location: Germany
Posts: 527
Default

hi,
this somehow works:
PHP Code:
temp$=str(points$); //points$ is a number
G_SHOWMESSAGE(wstr(temp$[1,0])); 
and this combination also:
PHP Code:
temp$=points$+""//points$ is a number
G_SHOWMESSAGE(temp$[1,0]+""); 
maybe kornalius can explain why a double conversion is needed.
Reply With Quote
  #3  
Old 10-04-2009, 05:04 PM
sdkfz250 sdkfz250 is offline
Member
 
Join Date: Jul 2009
Posts: 36
Default

Hey, you answered so quick. That's realy great.

Thanks for your help.

Michael
Reply With Quote
  #4  
Old 10-04-2009, 06:58 PM
kornalius kornalius is offline
Administrator
 
Join Date: Apr 2006
Posts: 551
Default Re: Question regarding num conversion

This is something I will have to look into. You can also try using the mid() function as a replacement in the meantime.
__________________
Regards,
Alain Deschenes
ArianeSoft Inc.
http://www.arianesoft.ca
Reply With Quote
  #5  
Old 10-11-2009, 07:23 PM
kornalius kornalius is offline
Administrator
 
Join Date: Apr 2006
Posts: 551
Default

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.
__________________
Regards,
Alain Deschenes
ArianeSoft Inc.
http://www.arianesoft.ca
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:18 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright (c) ArianeSoft Inc.
Copyright © 2009 www.ppl-lang.com - All rights reserved
Web Design by BR Web Consulting Ltd