Ask The Readers
Robert Lock Richard Mansfield And Readers
If you have any questions (or answers to the questions printed below) please write to: Ask The Readers, COMPUTE! Magazine, P.O. Box 5406, Greensboro, NC 27403.
"There is a small design flaw in the way that Commodore BASIC chains between programs. The flaw is small, but, will result in certain strings disappearing (and being replaced by a string of BASIC tokens).
Strings defined in a program as a constant (i.e. A$= "Hello") are not allocated space in RAM. The pointer to that string points back into the program to the line containing the literal. This is normally fine, but when the program chains into another program, the string pointers now point to some piece of your new program. Now what?
The solution is to not use any strings assigned as a constant. The assignment above should be replaced by A$= "Hello" + "". The null concatenation insures that BASIC will copy the string to RAM somewhere, and it will still exist after chaining to the next routine. Please note that DATA statements count as constants in this context. Use READ A$:A$ =A$ + "" to copy the string to upper RAM.
This is all wasteful if you do not chain to other routines, or if you don't use the old variables in the new routine, but be careful. Certain tokens (like RETURN) will redefine the character set or window size, a real problem if you don't realize why it happened."