[EMAIL PROTECTED] wrote:
We have a need to overwrite/update the first record of a sequential file.
Sure I could write 2 sequential files and 'cat' them or make 2 passes
through the data extract to get the totals but I thought I has seen a way
to resent the pointer (thereby overwriting the first record).
Any ideas?
You can't do it using writeseq due to the nature of sequential files.
Not in Universe, not in Unidata, not under any OS except under very
strict conditions which start with the line lengths being exactly equal.
You *could*, if the file's not too large, read the file as a dynamic
record, change the contents of <1> and write it back. Which would
accomplish the same end, but through a different means.
Sample code, (written off of the top of my head), follows:
OPEN "", "&UFD&" TO F.UFD ELSE
CRT "Can't open &UFD&, (not likely!).
STOP
END
K.UFD = "Some.Sequential.File"
READ.REC:
READU D.UFD FROM F.UFD, K.UFD LOCKED
CRT "Locked, [NL] to continue: ":
INPUT DUMMY
GO TO READ.REC:
END ELSE ;* New record
D.UFD<1> = "BLAH-1"
D.UFD<2> = "BLAH-2"
WRITE D.UFD ON F.UFD, K.UFD ELSE
CRT "ERROR WRITING"
STOP
END
END THEN ;* Existing record
D.UFD<1> = "NEW-BLAH-1"
WRITE D.UFD ON F.UFD, K.UFD ELSE
CRT "ERROR WRITING"
STOP
END
END
Check my block structure above, I'm not 100% certain it's correct, and
yes, the writes should probably be internal subroutines with better
error handling, but hopefully this is sufficient to communicate the concept.
--
Allen; aegerton at pobox dot com
-------
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/