Edit: I knew someone else would chime in with the answer as I waffled on!
At a glance all your Text[id].id values will be 0 as you've never initialised them. You're running GetTextExists and CreateText with an ID of 0 all the time.
I would try swapping your line:
if GetTextExists(Text[Id].Id) = 0
for
if Text[Id].Id = 0
To check if the variable hasn't been initialised, and if not, let AppGameKit initialise it for you. So swap:
CreateText(Text[Id].Id, Text[Id].Text$)
With
Text[Id].Id = CreateText(Text[Id].Text$)
So your function looks like ...
function ShowLine(Id, PosX#, PosY#)
Text[Id].Text$ = "Line " + str(Id)
if Text[Id].Id = 0
Text[Id].Id = CreateText(Text[Id].Text$)
SetTextSize(Text[Id].Id, 5)
SetTextVisible(Text[Id].Id, 1)
else
SetTextString(Text[Id].Id, Text[Id].Text$)
endif
SetTextPosition(Text[Id].Id, PosX#, PosY#)
endfunction
I found the use of text[id].id quite confusing, as ID means very little and it may trip you up in the future and cause some head scratching. Typically what I do is name my variables in such a way that I know what type of object they're referring to, which saves me head scratching. So in this case I would personally use some prefixes like this:
type TextArray
txtId as integer
sText$ as string
endtype
This way whenever you see txtID the txt prefix alerts you to the fact this should always point to an AppGameKit text object ID.
I also use:
snd (sound ID)
obj (3d object)
img (image file)
tex (image file I'm using as a 3D texture)
spr (sprite)
etc.
Then I can have types such as (how I define a type)
Type Type_Warrior
obj as integer // ID to it's 3D object
fX# as float
fZ# as float // Position stuff
sprHealthBar // ID to its healthbar sprite
txtNameTag // ID to its text object name tag
endtype
dim typArrWarrior[10] as Type_Warrior
// or maybe
typWarrior as Type_Warrior
This is just how I like to do it. At a glance I can look at any variable like this ...
typArrWarrior[5].sprHealthBar
I know instantly this is a user defined type, and array, and I'm referencing an AppGameKit sprite ID. Overkill for some, but really useful for me to keep things organised. Sorry if this seems off topic but the whole text[id].id thing personally makes it harder for me to read the code.