Moving file pointer
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Moving file pointer
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.
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
bjb007,
Best,
Mark
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?bjb007 wrote:I wrote my prog to read from a file...
put -36 to -1 of myData....
then
put -1 to -5 of myData....
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Moving file pointer
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.
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.
-
- Posts: 179
- Joined: Sat Apr 08, 2006 11:08 pm
- Contact:
Re: Moving file pointer
The file operation you're looking for is "seek"
Best,
Mark
Code: Select all
seek to 35 in file someFile
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
Actually, it is possible to start reading from a file at a particular byte, without using the seek command.
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Ah! Seek...
Thanks everyone for the help.
Seems that the ravages of time are taking their toll.
I didn't remember that one. Seek. Seek. Seek.
Seems that the ravages of time are taking their toll.
I didn't remember that one. Seek. Seek. Seek.
-
- Posts: 179
- Joined: Sat Apr 08, 2006 11:08 pm
- Contact:
File Pointer
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.
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.
from the docs i gather that this should work, why doesn't it for you?
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.
Code: Select all
read at 23 for 20
read at theByte until end
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.
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode