Post by parzival on Feb 6, 2021 21:15:05 GMT
The C64 (maxi) is my first experience working with Commodore Basic.
I’m puzzled in particular by its response to any change from the standard upper case setting to lower case, in that it changes the entire screen, including what has already been printed or typed— and if changed back, everything changes again.
I see that I can use PRINT CHR$(142) and PRINT CHR$(14) to go back and forth, but since this apparently changes every statement in a basic program, it produces a problem with comparing strings.
For example: X$ becomes x$, both in the variable name AND the content. If I set X$=“WAVE” and then the program executes a ?PRINT CHR$(14) command to lower case, X$ magically becomes x$, and the content becomes “wave”. But if while in lower case I type “WAVE” using the shift key, this is not treated as the same as “wave”, and if I execute a PRINT CHR$(142), then “WAVE” becomes the related graphic characters and not a word at all.
Okay, that’s kind of nifty, and it’s good that because of this the language is capable of distinguishing between “wave” and “Wave.”
However, let’s say I want to create a program where the visible text is in a more readable lower case format, with upper case letters where we expect to find them, and then have an INPUt statement to accept a response from the reader, and then compare that response to the visible text, I can run into a problem:
Consider the following, entered in lower text mode to allow for the easy to read experience for the user:
10 z$=”He was walking in London.”
20 ?z$
30 input “What was he doing”; a$
40 If leftstring$(a$,7)=mid$(z$,8,7) then print “Correct!”
If this program runs in lower case, the user has to enter “walking” as the first word of their response to be correct. But if the user follows the typical human training to capitalize the first word of a written response, “Walking” would be treated as incorrect.
So, I want a way to catch this, so that whatever the user enters, regardless of case, can be accepted, whether the user types “WALKING”, “walking”, “waLking”, etc., etc.. In other words, I want the response to be treated as case neutral when compared to the stored string.
I don’t see a way to do this in BASIC, at least not one that wouldn’t be clumsy as heck. And if I have the program execute a CHR$(142) to set everything to upper case for the user’s answer, then what is already on the screen will shift into upper case— an ugly and inelegant solution.
Is there a way to shift from upper to lower case during a program without altering the entire screen?
I’m using this for a text adventure game. The intent is for the user to see something like:
[SCREEN] Welcome to Paradise Station, your vacation gateway to the Galaxy! What would you like to learn about? You may choose: Accommodations, Gift Shop, Recreation Areas, Restaurants, Spacedock.
[PLAYER TYPES] SPACEDOCK
[SCREEN] Okay, I will show you our Spacedock.
... and so on, with it irrelevant if the user types “Spacedock”, “spacedock”, “SpAcedoCk” etc.. The program captures the input, normalizes the case to match the list of acceptable responses or known words, and proceeds, with the screen never blinking or changing case.
Thanks for any help!
Please note: I know BASIC. I don’t know Machine Code, Assembler, or anything else. I’m not opposed to PEEK and POKE if they can be used in a non-kludgy way.
I’m puzzled in particular by its response to any change from the standard upper case setting to lower case, in that it changes the entire screen, including what has already been printed or typed— and if changed back, everything changes again.
I see that I can use PRINT CHR$(142) and PRINT CHR$(14) to go back and forth, but since this apparently changes every statement in a basic program, it produces a problem with comparing strings.
For example: X$ becomes x$, both in the variable name AND the content. If I set X$=“WAVE” and then the program executes a ?PRINT CHR$(14) command to lower case, X$ magically becomes x$, and the content becomes “wave”. But if while in lower case I type “WAVE” using the shift key, this is not treated as the same as “wave”, and if I execute a PRINT CHR$(142), then “WAVE” becomes the related graphic characters and not a word at all.
Okay, that’s kind of nifty, and it’s good that because of this the language is capable of distinguishing between “wave” and “Wave.”
However, let’s say I want to create a program where the visible text is in a more readable lower case format, with upper case letters where we expect to find them, and then have an INPUt statement to accept a response from the reader, and then compare that response to the visible text, I can run into a problem:
Consider the following, entered in lower text mode to allow for the easy to read experience for the user:
10 z$=”He was walking in London.”
20 ?z$
30 input “What was he doing”; a$
40 If leftstring$(a$,7)=mid$(z$,8,7) then print “Correct!”
If this program runs in lower case, the user has to enter “walking” as the first word of their response to be correct. But if the user follows the typical human training to capitalize the first word of a written response, “Walking” would be treated as incorrect.
So, I want a way to catch this, so that whatever the user enters, regardless of case, can be accepted, whether the user types “WALKING”, “walking”, “waLking”, etc., etc.. In other words, I want the response to be treated as case neutral when compared to the stored string.
I don’t see a way to do this in BASIC, at least not one that wouldn’t be clumsy as heck. And if I have the program execute a CHR$(142) to set everything to upper case for the user’s answer, then what is already on the screen will shift into upper case— an ugly and inelegant solution.
Is there a way to shift from upper to lower case during a program without altering the entire screen?
I’m using this for a text adventure game. The intent is for the user to see something like:
[SCREEN] Welcome to Paradise Station, your vacation gateway to the Galaxy! What would you like to learn about? You may choose: Accommodations, Gift Shop, Recreation Areas, Restaurants, Spacedock.
[PLAYER TYPES] SPACEDOCK
[SCREEN] Okay, I will show you our Spacedock.
... and so on, with it irrelevant if the user types “Spacedock”, “spacedock”, “SpAcedoCk” etc.. The program captures the input, normalizes the case to match the list of acceptable responses or known words, and proceeds, with the screen never blinking or changing case.
Thanks for any help!
Please note: I know BASIC. I don’t know Machine Code, Assembler, or anything else. I’m not opposed to PEEK and POKE if they can be used in a non-kludgy way.