Jump to content
IGNORED

A strange quick of Applesoft Basic


vol

Recommended Posts

I am perplexed by a strange quirk.  I haven't find any mention of this in any documentation.  Would anyone like to help me to get any explanation of the quirk.  It is about the work with text files.  Let's examine my example.

10 D$=CHR$(4)
20 PRINT D$ "OPEN F1"
30 PRINT D$ "WRITE F1"
40 PRINT "HELLO WORLD!"
50 PRINT D$ "CLOSE"

This program just creates a text file that has name F1.  Let's read this file.

10 D$=CHR$(4)
20 PRINT D$ "OPEN F1"
30 PRINT D$ "READ F1"
40 ONERR GOTO 80
50 GET A$
60 PRINT A$;
70 GOTO 50
80 PRINT:PRINT D$ "CLOSE"


This doesn't work for me.  I need to change line 60 with 

60 PRINT " " A$;


and this works!  I have checked this on MAME and MICROM8.  It seems the first printed symbol always disappears somewhere.
 

Link to comment
Share on other sites

Been a looooong time, but ISTR that anything I/O by PRINT or INPUT/GET after {CTRL-D}READ/WRITE is sent to the DOS data channel for that file until the command channel is {CTRL-D}CLOSEd.  What you are doing is GETting a character from the file then sending it right back to the data channel, which definitely is an error as the file is being READ.  I remember reading in an Apple 2 book in high school, chapter on file processing, that any first character other then {CTRL-D} bypasses the DOS channels (sends to screen) when in a file processing mode.  The space in your revised line 60 is doing that, and notice how the space does not print if you make line 60:

 

60 PRINT " ";A$;

 

There is some technical reason, but it is way beyond me.

 

As an aside, I never realized AppleSoft BASIC can do without semicolons in some print lists.

  • Like 1
Link to comment
Share on other sites

@OLD CS1 Thank you very much.  However I have not been able to find any mention that the READ command affects write operations or the WRITE command affects read operations.  Examples in the DOS Programmer's manual show that if a file is open to read then writing to the screen must work the usual way.  Moreover I can't find anywhere a kosher way to read an arbitrary text file! 🙁

Let me also add an example from page 64 of the manual

1000 GET C$: PRINT C$ ; (Read 1 character and echo it)

This line reads a char from a file and echoes it on the screen...  Maybe I missed something or it is just a old unfixed bug.

Link to comment
Share on other sites

I can confirm that the get method does fail under dos 3.3 on real hardware. However, using input to read the whole string and getting rid of the loop of reading and printing one character at a time works fine under 3.3. And slightly more efficient. 

 

 

IMG_3327.jpeg

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

7 hours ago, nick3092 said:

I can confirm that the get method does fail under dos 3.3 on real hardware. However, using input to read the whole string and getting rid of the loop of reading and printing one character at a time works fine under 3.3. And slightly more efficient.

I wonder if the difference is INPUT completes a full field or record, whereas GET does not.

  • Like 1
Link to comment
Share on other sites

19 hours ago, nick3092 said:

I can confirm that the get method does fail under dos 3.3 on real hardware. However, using input to read the whole string and getting rid of the loop of reading and printing one character at a time works fine under 3.3. And slightly more efficient. 

 

 

IMG_3327.jpeg

Thank you but please check the original code because INPUT can't help to read an arbitrary text file.

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...