Script - Hexadecimal variable in file... Log Out | Topics | Search
Moderators | Edit Profile

X-Ways Support Forum » Advanced Features » Script - Hexadecimal variable in filenames « Previous Next »

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

rjohnson
Posted on Monday, Feb 16, 2004 - 20:46:   

WinHex 11.25 sr7

Assign MyVariable 0xFFEEDD
CopyIntoNewFile "C:\file+MyVariable+.txt

The above lines, when used in a script
will create a file with the filename:
"file16772829.txt"
as expected.

Assign MyVariable 0xFFEEDD00
CopyIntoNewFile "C:\file+MyVariable+.txt
still works

but:
Assign MyVariable 0xFFEEDD01
CopyIntoNewFile "C:\file+MyVariable+.txt

or anything other than 00 in the fourth byte will yield unexpected results, sometimes no file is created, sometimes the variable portion of the name appears to be the Hex values converted to ASCII.

Is there a 3 byte (24bit limit) here?
This appears to be the case, after which, if 4 bytes or greater are used the conversion is ASCII, which can't always generate a legal filename and fails?


I would like to be able to use up to 8 bytes (64 bits).
BTW 8 bytes will work if 4 through 8 are all zeros as in 0xffeedd0000000000 (little-endian the trailing zeros are insignificant, if zeros?)

Thanks.
Top of pagePrevious messageNext messageBottom of page Link to this message

rjohnson
Posted on Monday, Feb 16, 2004 - 22:16:   

Why does the following script paste trailing zeros? What am I doing wrong? 'Paste' seems to add a trailing zero often and I have never figured out what I have been doing wrong (so I have been avoiding it).


create "c:\temp\pastepluszero.txt" 0
save
close

open "c:\temp\pastepluszero.txt"
write "12345678"
save
close

{open "c:\temp\pastepluszero.txt"
assign finish getsize dec finish
block 0 finish
copy
goto finish
paste
save
close}[8]
Top of pagePrevious messageNext messageBottom of page Link to this message

Stefan Fleischmann (Admin)
Posted on Monday, Feb 16, 2004 - 22:43:   

WinHex cannot deal with zero-size files, that's why a warning is issued when you create one with 0 bytes. It will automatically be enlarged to 1 byte (which is by default 0x00). If you paste data at offset 0, the 0x00 byte is moved accordingly. This is the same behavior like if you use the GUI of WinHex, not a script.

The concatenation of strings and variables in the parameter of the CopyIntoNewFile command interprets variables as an integer and expresses this integer value in ASCII notation only if it is "not larger than 2^24 (~16 Mio.)", in accordance with the documentation.
Top of pagePrevious messageNext messageBottom of page Link to this message

changfeng
Username: changfeng

Registered: N/A
Posted on Saturday, Sep 5, 2009 - 18:26:   

I have a test thet, your code "block 0 finish" hav a question. if you change it like this "block 0 (finish-1)",you can't find the zero .I think, blocksize can find 8,so the code "block 0 finish mean "block 0 8"=total 9. so have a zero. I don'know that my idea is right or not.

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.