Page 1 of 1
Moving file pointer
Posted: Wed Feb 13, 2008 6:53 pm
by bjb007
I wrote my prog to read from a file...
put -36 to -1 of myData....
then
put -1 to -5 of myData....
That worked OK
When I reversed these two lines it wouldn't work.
Seems that the file pointer is at -5.
Is there a way to move it using EOF?
I expect that 'read to EOF' would work but
would prefer 'go to EOF' or similar.
Re: Moving file pointer
Posted: Wed Feb 13, 2008 10:41 pm
by Mark
bjb007,
bjb007 wrote:I wrote my prog to read from a file...
put -36 to -1 of myData....
then
put -1 to -5 of myData....
I don't have the faintest idea what that means. It isn't valid Transcript. What are you trying to do? What is the actual script?
Best,
Mark
Moving file pointer
Posted: Wed Feb 13, 2008 11:23 pm
by bjb007
That's pseudo-code just to give the general idea.
Usually when a file is read the "pointer" or position
stays at the end of the last read. So if you want to
read again in some other location in the file you either
have to close and open or, in most languages, you can
send the pointer to the start or end (EOF) of the file.
Posted: Wed Feb 13, 2008 11:38 pm
by Mark
bjb007,
You might want to read the entry for "read from file" in the built-in docs.
Best,
Mark
Re: Moving file pointer
Posted: Wed Feb 13, 2008 11:55 pm
by Mark Smith
The file operation you're looking for is "seek"
Best,
Mark
Posted: Thu Feb 14, 2008 12:01 am
by Mark
Hi Mark Smith,
Actually, it is possible to start reading from a file at a particular byte, without using the seek command.
Best,
Mark
Ah! Seek...
Posted: Thu Feb 14, 2008 12:51 am
by bjb007
Thanks everyone for the help.
Seems that the ravages of time are taking their toll.
I didn't remember that one. Seek. Seek. Seek.
Posted: Thu Feb 14, 2008 2:27 am
by Mark Smith
Mark wrote:Hi Mark Smith,
Actually, it is possible to start reading from a file at a particular byte, without using the seek command.
Best,
Mark
Quite so, I'd forgotten about 'read from ... for ... at..."
Best,
Mark
File Pointer
Posted: Thu Feb 14, 2008 1:22 pm
by bjb007
Thanks all for comments but still seems to be no
way to go to start or end of file without closing
and re-opening except "Read to EOF" which seems
to put the whole file into variable "it".
BTW haven't seen anything in the docs about
1. Releasing variables
2. Meanings of error messages.
Any info would be appreciated.
Posted: Fri Feb 15, 2008 12:36 am
by BvG
from the docs i gather that this should work, why doesn't it for you?
Code: Select all
read at 23 for 20
read at theByte until end
variables are released when the handler quits, unless when you specified them as global or local (local with caveat). If you forcibly want to get rid of data, most of the time it's enough to put empty int a var. To really delete variables, check out the "delete variable" command in the documentation.
The errors you get in rev are most of the time not helpful, often they point to the wrong line, have the wrong description, and/or are otherwise unhelpful. On the plus side you'll learn to make code that has almost no errors sooner or later. If you got a special case you want to have more information about, then post your code, and the error that rev reports.