string to integer

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
rblack
Pro Scripter
Posts: 87
Joined: Sat Dec 22, 2007 12:39 pm

string to integer

Post by rblack » Thu Aug 05, 2010 3:16 pm

hello,

i have a file with a number in each line, but when i use the command:

ReadLn>file.txt,line,number

the number variable is returned as string, and i cannot do mathematical calculations on it (which i need). What is the fastest way to force integer, or convert string to int ?

Had anyone got a solution for that?

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Aug 05, 2010 3:41 pm

Strings/numbers are interchangeable in Macro Scheduler. However, if you have any spaces or other characters in the string it will not work as a number.

So that maybe your issue. Try:

ReadLn>file.txt,line,number
Trim>number,number

If that doesn't work there must be some other hidden character in there.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

rblack
Pro Scripter
Posts: 87
Joined: Sat Dec 22, 2007 12:39 pm

Post by rblack » Thu Aug 05, 2010 3:51 pm

this line:

Trim>number,number

makes the number variable empty, i think that the hidden character is CRLF because i can see it in notepad++

rblack
Pro Scripter
Posts: 87
Joined: Sat Dec 22, 2007 12:39 pm

Post by rblack » Thu Aug 05, 2010 5:14 pm

Separate>file,CRLF,number

and reading each number_n solved the problem

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts