Includes can have more than functions, but they go at the end of the main source file, just as if they were other source files in the project, not "in-place".
Here is a sample of what I mean. Its contrived, but I want to tell you that alot of people complained about array index valid as a range check, because it does not work very well as a range check, but array count does.
This first bit is the main source:
+ Code Snippetdim players() as PLAYER
global i as integer
print "players() contains " + str$(array count(players()))
for i = 0 to 15
array insert at bottom players()
select i
case 0
players().name = "Alpha"
players().number = 1024
endcase
case 1
players().name = "Bravo"
players().number = 11
endcase
case 2
players().name = "Charlie"
players().number = 64
endcase
case 3
players().name = "Delta"
players().number = 1024
endcase
case 4
players().name = "Echo"
players().number = 5
endcase
case 5
players().name = "Foxtrot"
players().number = 1
endcase
case 6
players().name = "Golf"
players().number = 334
endcase
case 7
players().name = "India"
players().number = 12
endcase
case 8
players().name = "Juliet"
players().number = 3
endcase
case 9
players().name = "Kilo"
players().number = 12235
endcase
case 10
players().name = "Lima"
players().number = 7
endcase
case 11
players().name = "Mike"
players().number = 698
endcase
case 12
players().name = "November"
players().number = 557
endcase
case 13
players().name = "Oscar"
players().number = 87
endcase
case 14
players().name = "Papa"
players().number = 709
endcase
case 15
players().name = "Quebec"
players().number = 3678
endcase
endselect
next i
print "players() contains " + str$(array count(players()))
PrintPlayers()
wait key
cls
array insert at element players(), 7
players(7).name = "Hotel"
players(7).number = 9999
PrintPlayers()
do
loop
end
I use the arrays by defining them and functions for accessing them in a separate file, usually with my "jz" brand on them. Here is the file that goes with the code above. You could put it with the other code, too.
+ Code Snippettype PLAYER
name as string
number as integer
endtype
function PrintPlayers()
local i as integer
for i = 0 to 16
if array count(players()) > -1
if i <= array count(players())
print players(i).name + " : " + str$(players(i).number)
endif
endif
next i
endfunction
Notice the dim players() at the top of the main source. Also, notice that the type is defined (in my case) in a different file, and the functions that use it are there, too. In order for this to compile, the dim must be in the main file. After that, it is all gravy.
It will print out the array count before any elements are added, and then again after. Then, it will print the array elements. Notice that there is no "H" player. Press a key, and "Hotel" will be inserted at its correct position, and it will print out again.