First, print statements with variables are okay. You can't use them concatenated with strings, but they work fine by themselves.
This works...
nImage = 5
do
print(nImage)
sync()
loop
but this does not work...
nImage = 5
do
print("The value is " + nImage)
sync()
loop
Second, you gotta keep in mind that variables declared in functions are local to that function. So...
load()
do
print(nImage)
sync()
loop
function load()
nImage = LoadImage("Image.png")
endfunction
will always have the nImage referred to in the print statement as a value of zero. If you use the same method to create a sprite in a function then you'll get a crash because there's no sprite zero allowed.
But...
global nImage
load()
do
print(nImage)
sync()
loop
function load()
nImage = LoadImage("Image.png")
endfunction
will work fine, because the nImage variable used in the function is global, and thus is the same variable called in the print statement.
So the variable iconImage declared in a function, unless declared global outside the function, will return zero when referenced outside of the function. And a sprite created with a local variable in a function will not be the same sprite referenced in a local variable with the same name outside that function.
Try this...
makeSprite()
do
print(nSprite)
sync()
loop
function makeSprite()
nSprite = createsprite(0)
endfunction
and you'll see what I mean.
In AppGameKit, arrays are always global, so you don't have to bother declaring them global.
Third, when AppGameKit crashes, it can be problematic to find the cause if you are adding several lines of code.
It might be that the error is in the line that attempts to delete gCurrentSprite, which might be zero because of #2 above.
I have had no problems with printing string literals. If you truly are having problems with printing string literals, then maybe a reinstall of AppGameKit would fix it.
EDIT: I got no clue why my code and /code tags aren't working.
I used to hate the thought of governments having orbital mind control satellites,
but now I can't really seem to care.