1. Restore

Euphoria apparently has no command corresponding to 'restore' in BASIC.
Without it, I have to open a file inside a subroutine, say 'get', 'get',
'get', ... in a loop until I find what I am looking for in the file, then
close the file.  Next time I enter the subroutine, I open the file again and
start over.

This seems inefficient.  I'd rather open the file once outside the
subroutine, leave it open, and start at the beginning of the file whenever I
enter the subroutine.  But without the pseudo-'restore' command, the next
time around I begin looking in the file where I left off before.

Have I overlooked something?

Wally Riley
wryly at mindspring.com

new topic     » topic index » view message » categorize

2. Re: Restore

> Euphoria apparently has no command corresponding to 'restore' in BASIC.
> Without it, I have to open a file inside a subroutine, say 'get', 'get',
> 'get', ... in a loop until I find what I am looking for in the file, then
> close the file.  Next time I enter the subroutine, I open the file again and
> start over.
>
> This seems inefficient.  I'd rather open the file once outside the
> subroutine, leave it open, and start at the beginning of the file whenever I
> enter the subroutine.  But without the pseudo-'restore' command, the next
> time around I begin looking in the file where I left off before.

Read up on the seek() command in the manual.

Michael Bolin

new topic     » goto parent     » topic index » view message » categorize

3. Re: Restore

> This seems inefficient.  I'd rather open the file once outside the
> subroutine, leave it open, and start at the beginning of the file whenever I
> enter the subroutine.  But without the pseudo-'restore' command, the next
> time around I begin looking in the file where I left off before.

Use the "seek()" function. If you want to 'resume' the last positon
you accesed in the file, you can store 'where()' in a variable and
then 'seek()' to it.

Regards,
  Daniel Berstein
  danielberstein at usa.net
  http://www.geocities.com/SiliconValley/Heights/9316

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu