5

I'm writing a little hobby c64 textual adventure and I've stopped in one very concrete moment. Namely, I don't know how to quote anything inside quote.

How to do that inside commodore 64 basic v.2.0.?

Dijkgraaf
  • 11,049
  • 17
  • 42
  • 54
perpetuum
  • 129
  • 10

1 Answers1

12

You have to generate a string containing the quote character some other way than as a literal. The obvious way is to use CHR$, as in:

? "ONE ";CHR$(34);"QUOTED";CHR$(34);" WORD"

One of the examples at http://www.c64-wiki.com/index.php/CHR%24 is quite similar to this.

If you have to do a lot of them, you could store it in a variable to make the code shorter (which may make it faster or slower - if this matters, measure it yourself)

10 QU$ = CHR$(34)
20 ? "ONE ";QU$;"QUOTED";QU$;" WORD"
  • 1
    Extraordinary. Why if I want to stress an any word within a string with white color (or any), one time c64 react with properly inversed e character (as a result of hitting the number two after reversing on ctrl+9 as c64 manual states it) and in another time it, instead of a proper reversed "e" it gives an either number "2" or changes cursor to white or if I hit two on the keyboard with combination of ctrl it gives brown cursor... anything but a previously already proper stamped inversed "e"??? – perpetuum Dec 11 '14 at 00:17
  • 2
    That sounds like it should be a separate question. Anyway, as you can see in [this chart](http://sta.c64.org/cbm64petkey.html) Ctrl-2 is for white, C=-2 (The Commodore logo key and the 2 key) is for brown. The C= key is in the lower left corner of a C64 keyboard, where Ctrl is on most IBM-PC-descendant keyboards. So I suspect you don't have a real C64 keyboard, you're using an emulator and the key layout is confusing you. –  Dec 11 '14 at 00:45
  • Yes, vice emulator which one time notifies and the other time don't when "reverse" is turned on. But only when it signalise with inverted "R" it then receives my input for white color code(which I want) and not the white colored cursor at itself. When there is no "R" it inverses but not giving me "inverted E" which I want but just an either (") or (2).... I don't know how to invoke real inverting with "inverted R" which signalises real inverting mode that is turned on...(which of course gives me so wanted "inverted E" code for white... – perpetuum Dec 11 '14 at 01:14
  • Forget it... I think I know... I wanted to edit the line of my program but it properly turns on reverting just if you are writing the line from the beggining (of line itself)... not sure but I now will check again... – perpetuum Dec 11 '14 at 01:27
  • 3
    Sounds like you need to study up on the input modes. In normal mode, Ctrl-2 turns the cursor white immediately. In quote mode (when you have typed a quotation mark to begin a string and haven't typed the second one to finish it yet) the "change foreground color to white" control character is inserted into the string instead of taking effect immediately. A string that contains control characters shows them as various reversed symbols. There's also an "insert mode" initiated by the Insert key (Shift-Del). You need to keep track of which mode you're in... –  Dec 11 '14 at 01:41
  • In vice, it left symbols as they are in the final output "inverted e" in front of the word in code with "inverted cross" for backing track of default color of my adventure, lightest grey. But I think that is because of mine using of alternative code for lightest grey, namely commodore(pc ctrl) + eight instead of control + dash(on pc, it do not want to invert with these two in quote mode). So, first word of before some day (is) properly whitened(I don't know how then I did it... but this time, this word remained in output of adventure as it is in code, "inv.e" before and "inv.cross" after... – perpetuum Dec 11 '14 at 02:21
  • Yes this one which doesn't want to work is inside the "citate" formed by chr$(34) variable qu$... and because it maybe outputs the raw code instead of the efect of the code... – perpetuum Dec 11 '14 at 02:28
  • In both your examples, the semicolons are redundant. They can be removed and the program will run a bit faster (though it may be slightly less readable). – Psychonaut Nov 15 '15 at 18:13