A Stringy Situation

Avoiding GLOBAL Vars in AUTOEXEC

This page assumes you're already familiar with the use of GLOBAL variables and functions.
The cleverness of a botmaker can often be strained by a multiplicity of global variables, especially when scheduling a lot of ALARMEXEC events. Sometimes, it becomes a major hassle to figure out just what value a particular global var might have by the time the event actually gets around to executing.
A workaround is available that completely erases the need for many such global variables, assuming that you can either know or calculate the value you want the variable to have by the time ALARMEXEC will get to your atom list. The trick is to just turn the variable value(s) into string constants using ITOA, include the strings as part of a larger string, then use STRTOATOM to convert the string back to an atom list with no variables, and ALARMEXEC it!
Confused yet?
Here's an example, an alternative version of glide_to_plain that manages to work without any GLOBAL calls at all. Pleasingly, it's actually smaller than the original.

; <x> <y> glide_strat EXEC
;   glides from the current position to a new one, NO PROP CHANGES
    glide_strat    GLOBAL
                    endY	=
                    endX	=
        POSX        strX	=
        POSY        strY	=
        strX strY SETPOS
        endX strX - dx		= 
        dx 22 /     nFrames	=
        { -1 nFrames *= }    0  nFrames > IF
        { 12 nFrames  = }    nFrames 12 > IF
        {  4 nFrames  = }    nFrames  4 < IF
        0           counter	=
        30          arcdel	=
	    endX strX - counter * nFrames 1 - / strX + nx =
	    endY strY - counter * nFrames 1 - / strY + ny =
	    nx ITOA " " & ny ITOA & " SETPOS" & STRTOATOM arcdel ALARMEXEC
            30 arcdel +=
            counter ++
        } { counter nFrames < } WHILE
    } glide_strat DEF

Important Practical Limitation:
These is a squirrelly bug in old versions of Iptscrae: quotation marks appearing inside strings were often messed-up or surrounded by superfluous spaces. This can make text-intensive uses of STRTOATOM troublesome.
A good way to get rid of this trouble is to use hex escape sequences in strings that are destined for STRTOATOM hex escapes are: backslash and x followed by the two-digit hexadecimal value for the character's ASCII code. They're common in C and Perl programming. For example, instead of a " mark, use \x22 in fact, there are a few values that I personally use everywhere in strings these days, since they make the resulting Iptscrae code a little easier to navigate in a text editor, and they prevent a few pathological iptscrae parsing errors.

Symbol Equivalent Hex String
" \x22
; \x3b
[ ] \x5b \x5d
{ } \x7b \x7d
<RETURN> \x0d