Jump to content
  • 0

Interesting Result With Color Command


Drunk Chicken
 Share

Question

Hey guys.

It's my first time using BASIC in many years and I wrote a very basic program to fill up the screen with random characters.

image.png.9440ee866388c46e860e64d2356471d5.png

I then added a line which I thought would change each character to a random color before printing.

It produced the below result. Strangely, every time a " is printed, it ignores the loop and prints off random characters in one color until another " is printed.

image.png.6cc6dc910df8dab623c0ef10870ab6bf.png

Any idea why this is the case?

I'm just curious more than anything else 🙂

Thanks!

  • Like 1
Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Very strange. Just trying to recreate from the interpreter shell doesn't work you can do a PRINT CHR$($22) and get a quote in the current color, do another color command, and it appears to take hold, as the next character you print comes out in the new color. So, this is something weird happening in the BASCI interpreter or the kernal that is glossed over when putting in commands through the shell, presumably do to something that happens when regenerating the READY prompt.

Link to comment
Share on other sites

  • 0

Ok, it has something to do with the semicolon. If you omit the semicolon, you get newlines between each character, but the color keeps changing:

x16_colors_chars.png.dc9cb9a5b58b01d6edd0ddde2d894007.png

If you put in the semicolon, all the characters are printed in a single line, and they are all red after the "

image.png.227a2a5420be6a191a66460e6c136986.png

Edited by SlithyMatt
Link to comment
Share on other sites

  • 0

Look closely at the second picture just above here.  Notice that the program printed more than 16 characters across the line.  There is a reversed graphic character in between each punctuation mark after the quotation mark.  Those are the PetSCII color control characters.  They're displayed instead of obeyed when Kernal is printing in "Quote mode".

Apparently, COLOR doesn't store color numbers directly into a Kernal variable.  Instead, it prints PetSCII control codes.  That method of changing colors can't work in Quote mode!

Your little random program could test which character just was printed.  If the code number is 34, then print that character again.  That will turn quote mode off; and, you'll get the many-colored screen that you want.

  • Like 2
Link to comment
Share on other sites

  • 0

You know, I didn't notice until now that in my second program there were random PETSCII graphics characters in between the expected characters. It's like a weird Mandela Effect thing. They couldn't have been there before, could they?

So this "Quote Mode" thing is weird. If I am programmatically printing something, why should it behave as if I am live typing into the BASIC shell? How would you just print out a quote character without triggering this behavior?

Link to comment
Share on other sites

  • 0
1 hour ago, SlithyMatt said:

So, this "Quote Mode" thing is weird. If I am programmatically printing something, why should it behave as if I am live-typing into the BASIC shell? How would you just print out a quote character without triggering this behavior?

It allows BASIC's LIST command to show any control characters that are embedded into string literals.  The LIST command can be written into programs.  Therefore, Kernal doesn't "ask" whether the printing is happening while a program is running or not -- the mode always works.

The universal way to print a quotation mark without being left in quote mode is to print it twice, but with a "delete" control character in between them.  (The two carriage-return controls and delete are immune to quote mode.)  The second mark is printed in place of the first one.

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.

Guest
Answer this question...

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

 Share

×
×
  • Create New...

Important Information

Please review our Terms of Use