Clean way to append data to a file by... Log Out | Topics | Search
Moderators | Edit Profile

X-Ways Support Forum » Advanced Features » Clean way to append data to a file by script « Previous Next »

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

Anonymous
Username: anonymous

Registered: N/A
Posted on Saturday, Jun 9, 2007 - 19:12:   

The Task is to to append data from another file (for ex. "C:\DataToAppend.dat") at the end of the current file.

So this script should do the Task:
// 1. Get Data To Append 
open "C:\DataToAppend.dat"
Copy
close

// 2. Seek to the very end of the file...
goto GetSize

//3. ...and append data there
WriteClipboard


BUT Instead I get an error:
"The File don't contain the Offset ...."

The problem is the second task need to seek to the very end of the file by the command 'goto GetSize'.
Well 'goto (GetSize-1)' works but will paste data one byte before the end. But a 'move 1' to compensated that and to reach the final EOF is also blocked by Winhex.

Finally
... 
// 2. Seek to the very end of the file...
goto (GetSize-1)
Read Buff 1
Write Buff
...
works but it's a not very 'clean' solution.

This is probably due to a so call 'fence post' error or something like that - a matter of '>' or >=' in the source code.

Anyway any ideas how to improve this?
Top of pagePrevious messageNext messageBottom of page Link to this message

Stefan Fleischmann
Username: admin

Registered: 1-2001
Posted on Saturday, Jun 9, 2007 - 19:25:   

That the current position cannot be moved past the end of the file may be undesirable, but it's not an error in scripting. It's not possible in the user interface either with the blinking cursor (caret). It was suggested before to allow for this, and it's on our To Do list, along with 630 other items.

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.