Script function to read text as an in... Log Out | Topics | Search
Moderators | Edit Profile

X-Ways Support Forum » Advanced Features » Script function to read text as an integer « Previous Next »

Author Message
Top of pagePrevious messageNext messageBottom of page Link to this message

howard@apextechnology.co.uk
Posted on Monday, Nov 14, 2005 - 10:27:   

Hi,

I have a text file which stores decimal file offset values on separate lines. eg,

100
200
300

The idea is that I could read these offset values one at a time, open another file and change the value at that offset position.

The script is something like this...
Assign changeByte 0x33

// Read offset values
Open C:\offsets.txt
Readln MapOffset

//open the file to be altered
Open C:\abcdefgh.dat
Goto MapOffset
Write changeByte
Save

The difficulty is that Readln will read the Hex values, and so for the first line in offsets.txt the offset 100 is interpretated as 3158065.

While I realise this is correct operation I wondered if a function or work-around is possible to read/interpret 100 as a decimal integer?

Alternatively a small script to do a conversion would be required. Maybe use a separate vbscript to pre-process the offsets.txt file.

Any suggestions/help appreciated. Thanks.
Top of pagePrevious messageNext messageBottom of page Link to this message

Stefan Fleischmann (Admin)
Posted on Friday, Nov 18, 2005 - 6:06:   

> The difficulty is that Readln will read the Hex values

ReadLn reads any kind data, exactly as stored, not the ASCII character representation of numbers in decimal notation, also not hex values. Hex values are just a certain kind of representation of binary data as stored on the disk.

> wondered if a function or work-around is possible to
> read/interpret 100 as a decimal integer

From the program help and user manual:

StrToInt MyInt MyStr
Stores the binary representation of the integer number specified as a decimal ASCII string in the second parameter in a variable specified as the first parameter.
Top of pagePrevious messageNext messageBottom of page Link to this message

howard@apextechnology.co.uk
Posted on Friday, Nov 18, 2005 - 9:55:   

Many thanks Stefan,

Sorry I had read the help file and mistakenly tried IntToStr. Now I realise StrToInt was the solution!

Anyway it now works as I required:-)

Thanks again for your assistance

Add Your Message Here
Post:
Username: Posting Information:
Only registered users may post messages here, i.e. you need to have an account.
Password:
Options: Enable HTML code in message
Automatically activate URLs in message
Action:
Forum operated by X-Ways Software Technology AG.