Jump to content
IGNORED

Adding strings to a FIXED file


moulinaie

Recommended Posts

Hello,

 

I have a file (DISPLAY, FIXED 80), and I want to open it to add strings at the end of the file.

I can't !!

 

I have tried OPEN with DISPLAY, FIXED 80 and APPEND can't be used in the case of FIXED lenght

I have tried OPEN with DISPLAY, FIXED 80 and UPDATE but when I write with PRINT it overwrites the old file...

I have tried to open and then use RESTORE to go to the end of the file.... No more success, error on the RESTORE line

I have tried to open with UPDAT and read previous strings to go to the end... error on the first read, it looks like it is at the end of the file...

So, if at the end... why does it overwrites the previous lines when I use PRINT ?????

 

Can anyone help???

 

Guillaume.

Link to comment
Share on other sites

That's interesting, not something I was aware was a problem.

 

The easy (and slow) way is probably to open it in UPDATE mode, read till EOF, then write.

 

The easy/slightly faster way would require you to store how many records you have (or if you are in assembly, you can get the file information), and then explicitly specify the record you want to write in the PRINT statement:

 

PRINT #file-number [.REC record-number] [:print-list]

 

Someone might have something better :)

Link to comment
Share on other sites

That's strange. The following works in classic99:

 

Write out some records:

10 OPEN #1:"DSK1.MARK",OUTPUT,DISPLAY ,FIXED 80
20 FOR I=1 TO 10
30 PRINT #1:STR$(I)
40 NEXT I
50 CLOSE #1
RUN
NEW

 

Write some more records to the end of the file in append mode:

10 OPEN #1:"DSK1.MARK",APPEND,DISPLAY ,FIXED 80
20 FOR I=1 TO 10
30 PRINT #1:STR$(RND)
40 NEXT I
50 CLOSE #1
RUN
NEW

 

Now read all records back in:

 

10 OPEN #1:"DSK1.MARK",INPUT ,DISPLAY ,FIXED 80
20 IF EOF(1)THEN 60
30 INPUT #1:A$
40 PRINT A$
50 GOTO 20
60 CLOSE #1

 

All works with no errors... :?

Link to comment
Share on other sites

That's strange. The following works in classic99:

 

Write out some records:

10 OPEN #1:"DSK1.MARK",OUTPUT,DISPLAY ,FIXED 80
20 FOR I=1 TO 10
30 PRINT #1:STR$(I)
40 NEXT I
50 CLOSE #1
RUN
NEW

 

This one works!

 

Write some more records to the end of the file in append mode:

10 OPEN #1:"DSK1.MARK",APPEND,DISPLAY ,FIXED 80
20 FOR I=1 TO 10
30 PRINT #1:STR$(RND)
40 NEXT I
50 CLOSE #1
RUN
NEW

 

Here, I get IO ERROR 02 in 10, it refuses the APPEND mode.

 

Guillaume.

Link to comment
Share on other sites

Looks like:

 

10 OPEN #1:"DSK1.MARK",UPDATE,DISPLAY,FIXED 80,RELATIVE
15 RESTORE #1,REC 10

 

this works to add recors after the thenth.

 

We said before that CLASSIC doesn't emulate the disk system of the TI99, that explains the difference.

 

 

Guillaume.

Link to comment
Share on other sites

Hmmm... Is that an issue with the CF7 DSR I wonder??

 

I mean, if you are opening in APPEND then it implies you want to WRITE. I think this should be checked out on a real TI with PEB and TI disk controller.

 

Is there anybody out there that can check?

 

If there's an issue with the CF7 DSR then we can inform the CF7 guy (can't remember his name!)

Link to comment
Share on other sites

Hmmm... Is that an issue with the CF7 DSR I wonder??

 

I mean, if you are opening in APPEND then it implies you want to WRITE. I think this should be checked out on a real TI with PEB and TI disk controller.

 

Is there anybody out there that can check?

 

If there's an issue with the CF7 DSR then we can inform the CF7 guy (can't remember his name!)

 

No, I made the test on a real PEB.

 

Guillaume.

Link to comment
Share on other sites

Hmmm... Is that an issue with the CF7 DSR I wonder??

 

I mean, if you are opening in APPEND then it implies you want to WRITE. I think this should be checked out on a real TI with PEB and TI disk controller.

 

Is there anybody out there that can check?

 

If there's an issue with the CF7 DSR then we can inform the CF7 guy (can't remember his name!)

 

Yeah, according to the XB manual, APPEND mode does not work with FIXED format. It should IMHO. I cannot imagine why the TI programmers would do that!

 

CF7 guy is Custodio Malilong.

 

...lee

Edited by Lee Stewart
Link to comment
Share on other sites

Yes, Classic99 has a Classic99 filesystem. It does not attempt to be a TI, Corcomp, or Myarc disk controller, rather it's an interface to the Windows file system. It does not enforce restrictions that I was not aware of or didn't agree with, like not being allowed to append to a fixed length file. (Which is bizarre -- it's easier than a variable length file!) Every different disk controller, including the RAMdisks, has slight differences.

 

The XB manual, the disk controller manual, and Thierry's site all concur that you are not allowed to APPEND to a FIXED record file. Just weird.

 

These differences are why I do need to implement support for the real disk controller card in Classic99, someday. I don't think it's generally useful, but for testing against the disk system it's mandatory.

Link to comment
Share on other sites

didn't agree with, like not being allowed to append to a fixed length file. (Which is bizarre -- it's easier than a variable length file!)

 

I said the same thing to myself.

But the FIXED files can be appened with new data with UPDATE+RELATIVE flags and then using RESTORE to go to the end of the file as I said before, so it's not impossible on a real TI, just a little harder as you must know the length of the file...

 

10 OPEN #1:"DSK1.MARK",UPDATE,DISPLAY,FIXED 80,RELATIVE
15 RESTORE #1,REC n
n being the number of records in the file.

 

 

 

These differences are why I do need to implement support for the real disk controller card in Classic99, someday. I don't think it's generally useful, but for testing against the disk system it's mandatory.

 

Yes, that would be a "plus" !

Guillaume.

Edited by moulinaie
Link to comment
Share on other sites

...

But the FIXED files can be appened with new data with UPDATE+RELATIVE flags and then using RESTORE to go to the end of the file as I said before, so it's not impossible on a real TI, just a little harder as you must know the length of the file...

 

10 OPEN #1:"DSK1.MARK",UPDATE,DISPLAY,FIXED 80,RELATIVE
15 RESTORE #1,REC n
n being the number of records in the file.

...

Guillaume.

 

You don't need to know the number of records in the file with the following:

 

10 OPEN #1:"DSK1.MARK",UPDATE,DISPLAY,FIXED 80,RELATIVE
20 RECNO = 0
30 RESTORE #1,REC RECNO
40 IF EOF(1) THEN 70
50 RECNO = RECNO + 1
60 GOTO 30
70 REM File is pointing now to end of file

 

...lee

Link to comment
Share on other sites

You don't need to know the number of records in the file with the following:

 

10 OPEN #1:"DSK1.MARK",UPDATE,DISPLAY,FIXED 80,RELATIVE
20 RECNO = 0
30 RESTORE #1,REC RECNO
40 IF EOF(1) THEN 70
50 RECNO = RECNO + 1
60 GOTO 30
70 REM File is pointing now to end of file

 

...lee

 

Hehe! That's a way to "know" the number of records...!!!

It would be interesting to fasten this algorithm with the use of "power of 2".

 

Guillaume.

Link to comment
Share on other sites

Hehe! That's a way to "know" the number of records...!!!

It would be interesting to fasten this algorithm with the use of "power of 2".

 

Guillaume.

 

The way I have always tracked fixed file records is to use record 0 to store the total records. To do so, you should use it as a RELATIVE file. This serves two purposes:

  1. You know the last record written
     
  2. You may reserve file space without actually using the last record

10 OPEN #1:"DSK1.TEST",DISPLAY,FIXED 80,RELATIVE
20 FOR A=1 to 10::PRINT #1, REC A:"RECORD NUMBER: "&STR$(A) :: NEXT A
30 PRINT #1,REC 0: 10
40 CLOSE #1
50 OPEN #1:"DSK1.TEST",DISPLAY,FIXED 80,RELATIVE
60 INPUT #1,REC 0: A
70 FOR B=1 to A::INPUT #1,REC B:A$:: PRINT A$::NEXT B
80 CLOSE #1

 

In line 30 I did not print A as the total records, only because I could not remember if A will have increased to 11 at this point ;)

 

tim

Edited by InsaneMultitasker
  • Like 1
Link to comment
Share on other sites

The XB manual, the disk controller manual, and Thierry's site all concur that you are not allowed to APPEND to a FIXED record file. Just weird.

 

The following document (p.11) refers to the APPEND limitation being imposed by the console:

 

ftp://ftp.whtech.com/datasheets%20and%20manuals/Specifications/Fundamental%20Specs%20for%20Disk%20Peripheral.pdf

 

It would be an interesting exercise to test the APPEND mode outside of the BASIC environment. I have written fixed files sequentially but cannot recall ever adding to a fixed record file without knowing the record I intended to write.

 

This same WHT folder contains a few other good reference documents for the assembly programmer interested in file IO, including some best practices related to IO status byte and condition bit handling after a DSRLNK call. One such doc:

ftp://ftp.whtech.com/datasheets%20and%20manuals/Specifications/File%20Management%20Specification%20for%20TI%2099_4%20Personal%20Computer%20V2.5%2002-25-1983.pdf

Edited by InsaneMultitasker
Link to comment
Share on other sites

It would be an interesting exercise to test the APPEND mode outside of the BASIC environment. I have written fixed files sequentially but cannot recall ever adding to a fixed record file without knowing the record I intended to write.

No real need, the disk controller DSR disassembly on Thierry's site makes it pretty clear that it's a global restriction.

 

*---------------------------------
* Opcode 0: Open
* --------------
* PAB 0: >00
* 1: file type <--- error code
* 2-3:
* 4: record length
* 5:
* 6-7: # of records (if output)
* 8:
*---------------------------------
A50C0 CLR 0
MOVB @>FBFE(15),0 get file attributes
BLWP @>005A(9)
DATA >8000 save R0
ANDI 0,>1600 keep fix/var and access mode
CI 0,>0600
JNE A50DC
A50D6 BL @A4C72 dis/fix, open as append: return with error
DATA >4000 "bad attribute

Link to comment
Share on other sites

The following document (p.11) refers to the APPEND limitation being imposed by the console:

 

ftp://ftp.whtech.com/datasheets%20and%20manuals/Specifications/Fundamental%20Specs%20for%20Disk%20Peripheral.pdf

 

It would be an interesting exercise to test the APPEND mode outside of the BASIC environment. I have written fixed files sequentially but cannot recall ever adding to a fixed record file without knowing the record I intended to write.

 

This same WHT folder contains a few other good reference documents for the assembly programmer interested in file IO, including some best practices related to IO status byte and condition bit handling after a DSRLNK call. One such doc:

ftp://ftp.whtech.com/datasheets%20and%20manuals/Specifications/File%20Management%20Specification%20for%20TI%2099_4%20Personal%20Computer%20V2.5%2002-25-1983.pdf

 

I cannot find any such limitation mentioned in the Editor/Assembler Manual or the TI Forth Instruction Manual. Sometime soon I will try to open a fixed-record file in APPEND mode with TI Forth and report back. It should be pretty simple to set up.

 

...lee

Link to comment
Share on other sites

No real need, the disk controller DSR disassembly on Thierry's site makes it pretty clear that it's a global restriction.

...

 

 

I cannot find any such limitation mentioned in the Editor/Assembler Manual or the TI Forth Instruction Manual. Sometime soon I will try to open a fixed-record file in APPEND mode with TI Forth and report back. It should be pretty simple to set up.

 

...lee

 

H-m-m-m, well, I guess that was premature! :P

 

...lee

Link to comment
Share on other sites

No real need, the disk controller DSR disassembly on Thierry's site makes it pretty clear that it's a global restriction.

 

*---------------------------------
* Opcode 0: Open
* --------------
* PAB 0: >00
* 1: file type <--- error code
* 2-3:
* 4: record length
* 5:
* 6-7: # of records (if output)
* 8:
*---------------------------------
A50C0 CLR 0
MOVB @>FBFE(15),0 get file attributes
BLWP @>005A(9)
DATA >8000 save R0
ANDI 0,>1600 keep fix/var and access mode
CI 0,>0600
JNE A50DC
A50D6 BL @A4C72 dis/fix, open as append: return with error
DATA >4000 "bad attribute

 

Good find, sir. This makes sense, since the attribute testing would normally be found in the DSR itself.

Link to comment
Share on other sites

Anyone every notice that the File Access of the TI is exactly the same as Sector Read/Write access lay out.

Well not exactly but so close as to be a template for all access using Files or Sector or Device.

 

I mean the Rewind/Restore is pretty much just like Sector Read/Write or Tape Read/Write or File Record Read/Write or Sound access in in GPL.

 

I think this is the beauty of the TI99/4A design.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...