Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 string to integer
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
maiku




PostPosted: Thu Aug 03, 2006 4:05 pm   Post subject: string to integer

I cant figure out how to get a string into an integer Evil or Very Mad . I know it has to be a transferable value like the string has to be "10453" but i cant figure out how to use intstr or strint (whichever i need to use) or strintok, which does something, but i dont know what it does. If there's a tutorial for this, could someone give me the link? or if you know how to do it, could you leave an example? thnx so much
Sponsor
Sponsor
Sponsor
sponsor
Mazer




PostPosted: Thu Aug 03, 2006 4:21 pm   Post subject: (No subject)

code:
var number : string := "123"
var value : int := strint(number)


I don't know if there's a tutorial for it here... actually, there probably is, but it wouldn't be worth looking through all those pages of tutorials for it.

Pro tip: in Turing, type a function name or keyword, and (with the cursor located on the word), press F9. The Turing reference will pop up and explain things about what you want to use.
richcash




PostPosted: Thu Aug 03, 2006 4:36 pm   Post subject: (No subject)

For strintok, it's a boolean function that tells you whether or not you can change a string into an integer. You know that a string must be convertable, so the strintok returns true when the string is convertible.

code:
var value : string := "324"
if strintok (value) then
     put strint (value)
end if


This is helpful just in case value is something like "dog", then it won't give you an error, since the 'put strint (value)' won't run because strintok returns false in the if statement.
TokenHerbz




PostPosted: Fri Aug 04, 2006 3:21 am   Post subject: (No subject)

im curious to weather or not other variations of "strintok" exist... Id look myself if it wern't time for bed... Smile
NikG




PostPosted: Fri Aug 04, 2006 2:45 pm   Post subject: (No subject)

TokenHerbz wrote:
im curious to weather or not other variations of "strintok" exist... Id look myself if it wern't time for bed... Smile
Just 3 versions I believe, all for converting numbers to strings: strintok, strnatok, strrealok
Albrecd




PostPosted: Sat Aug 05, 2006 12:56 pm   Post subject: (No subject)

If you're trying to get the number value of the characters in your string, use ord.

code:
var word : string := "hello"
put ord (word)
% or
put ord (word (2)) %for a specific letter
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: