| Title: | *OLD* ALL-IN-1 (tm) Support Conference |
| Notice: | Closed - See Note 4331.l to move to IOSG::ALL-IN-1 |
| Moderator: | IOSG::PYE |
| Created: | Thu Jan 30 1992 |
| Last Modified: | Tue Jan 23 1996 |
| Last Successful Update: | Fri Jun 06 1997 |
| Number of topics: | 4343 |
| Total number of notes: | 18308 |
How do I rewind a NEXT_LIST file?
Here is the script
.label start
next_list test.txt
get oa$display=$next_list_item
force
.pause 1
.if $next_list_item nes " " then .goto start
Each time the script is run it picks up from where it left off. I am
looking for a way to rewind the file to the first entry in test.txt.
Dump_cache before the next_list didn't help.
Test.txt contains ..
A
B
C
etc.
| T.R | Title | User | Personal Name | Date | Lines |
|---|---|---|---|---|---|
| 360.1 | Use TEXT_FILE instead | SHALOT::DUNCAN | Joe - CIS/EIC Doc. Mgmt. Solution Set Consultant | Mon Mar 30 1992 18:25 | 15 |
It sounds to me like the TEXT_FILE function might be a better fit for
you. NEXT_LIST modifies the file (leaving its context inside the
file).
.label start
TEXT_FILE OPEN #foo "test.txt" /read
TEXT_FILE READ #foo
get oa$display= #TEXT_FILE_REC
force
.pause 1
.if #TEXT_FILE_REC NES "" then .goto start
TEXT_FILE CLOSE #foo
Joe Duncan @ OPA
| |||||
| 360.2 | You could do it, but probably don't want to | WAYLND::HOWARD | Hail to the Redskins! | Mon Mar 30 1992 19:15 | 33 |
NEXT_LIST returns one null value to show it is at the end,
then displays the first one. Note that it always does this in cache,
not on the disk. It caches the file the first time it is used, and
deletes all copies on disk. A DUMP_CACHE [dataset] writes out the file.
It puts in a record "****" to mark its place.
You could make a copy of the file before you start using it in
TEST.HLD, then DUMP_CACHE TEST.TXT, then
.label start
COPY "TEST.TXT" "TEST.HLD"
next_list test.txt
get oa$display=$next_list_item
force
.pause 1
.if $next_list_item nes " " then .goto start
DUMP_CACHE TEST.TXT
COPY "TEST.HLD" "TEST.TXT"
The first NEXT_LIST will delete all copies of TEXT.TXT from disk, so
you don't need to PURGE_FILE.
NEXT_LIST always does disk IO because it references $NEXT_LIST_ITEM
each time. Then you have to do a disk IO to get the value. So it is
not as efficient as it might be. .1 probably has the right approach.
NEXT_LIST is a holdover from V1, when efficiency was not a major
concern; you usually only had one option. In V1 it wrote the file out
each time, as Frank described in a Small Buffer article.
Ben
| |||||
| 360.3 | ENTRY form | SHALOT::GEERDES | Mon Mar 30 1992 20:24 | 12 | |
What I have been using in many occasions is an entry form, with just one field of 132 characters (if any records are longer in your seq file, create more fields). The mode is /MODE=ENTRY and the file points to a logical which you assign to the sequential file you want to read. Then you can just go through the file record for record by doing a FOR loop: FOR SEQFILE DO GET #X = .TEXT\\DO SCRIPT I found that easier and faster in many occasions, and a rewind is just starting the FOR loop again. Ben | |||||
| 360.4 | 101 ways to do anything, Thanks | ODIXIE::BIRCH | Mon Mar 30 1992 22:28 | 4 | |
Thanks for all the good info. I had planned to use a seq. entry form
with a logical if the next_list didn't work out, but I haven't used
Text_file so I think I'll go that direction. Thanks again.
| |||||