Writing (1) Digit To The End Of A Dos File (AREV Specific)
At 17 MAY 2000 09:38:20PM Jim Dierking wrote:
Well Don was right, xlating and writing a dos file works great
unless the variable goes over the 64k limit, which happened.
I used the code Aaron recommended to obtain the length of the
dos file. "Length=Dir('f:\arev3_1\datavol\export.txt')"
How can I write a null value to the last digit of the DOS file?
TIA for the help, Jim Dierking
At 17 MAY 2000 10:21PM Larry Wilson - TARDIS Systems, Inc. wrote:
something like:
* open the DOS file
CurPos=0
Done=0
loop
OSBREAD Chunk from DosFileVar at CurPos LENGTH 64000
* read 64K chunks
* Check status here - look at the R/Basic book
* set EOF if end of fileif EOF thenCurPos += LEN(Chunk)Done=1end elseif Chunk thenCurPos += LEN(Chunk)
look at Steve Smith's bugs page at:[url=http://www.ozemail.com.au/~stsm/top5.htm]Steve's Bug List[/url]
this checks for a bug in AREVend elseCurPos -= 1
for some reason, EOF was missed on the last read, but this
is the end, so get the actual last posDone=1enduntil Done do
repeat
OSBREAD Chr from DosFileVar at CurPos LENGTH 1
if Chr=CHAR(26) then
* do you want to overwrite EOF?
* if so, just write, else CurPos -= 1 then write hereend else
if you want to overwrite the last char, write at CurPos elseCurPos += 1write whatever you wantOSBWRITE newChar on DosFileVar at CurPosend
be sure to look at Steve's remark.
tardis_systems@yahoo.com
(the icon below is real-time; if I'm not on, it asks to take a message
if I ring for a chat, you'll get a floating box that says to click
for a chat.)
At 17 MAY 2000 11:17PM Larry Wilson - TARDIS Systems, Inc. wrote:
Of course, if you don't need to look for anything else in the file, you could just do an INITDIR and DIR() and get the filezie then do a OSBREAD testchar from DosFileVar at FileSize-1 LENGTH 1 (remember that os OSBREAD, the file starts at 0, not 1) Then you don't need a loop.
At 18 MAY 2000 01:21AM Jim Dierking wrote:
Thanks for the help. Here's what worked…Jim
OSOPEN "UPS.TXT" TO UPS ELSE STOP
OSBWRITE "" ON UPS AT (Dir('f:\arev\UPS.txt') - 1)
OSCLOSE UPS
At 18 MAY 2000 01:39AM Larry Wilson wrote:
A few lines less than my first suggestion - nice succinct code.
Would you please send me your email address?
I thought that was you on the system around midnight but wasn't sure enough to try to trigger a chat (it's interesting what that little icon does!)
Later,
Larry
At 18 MAY 2000 09:16AM Don Miller - C3 Inc. wrote:
Just to be safe, check for the MOD 21930 bug before doing the read/write. See Steve Smith's top 5 AREV bugs. If you're at the magic number, back up one byte and read 1 byte. Then append your data to that byte and do the OSBWRITE there. E.G.
* COMPUTE BYTE POSITION TO WRITE AT AND STORE IT IN BYTE_POS
* CHECK FOR THE BAD PLACE PER STEVE AND SET FOOBAR TO 1 ELSE FOOBAR=0
IF FOOBAR THEN
BYTE_POS-=1OSBREAD HUNK FROM WHATEVER_FILE AT BYTE_POS,1HUNK:=MY_BYTEOSBWRITE HUNK ON WHATEVER_FILE AT BYTE_POSEND ELSE
OSBWRITE MY_BYTE ON WHATEVER_FILE AT BYTE_POSEND
HTH
Don Miller
C3 Inc.