There are no classes in CB.
You declare an array with the keyword Dim. An array is always global.
would make an array with
11 cells (0 to 10). The array type is Integer as default.
would make a String array.
To make a function you use the syntax: Function fName(param1, param2, ...) [Function code here] End Function
Code: Select all
Function HelloWorld()
Print "Hello World"
EndFunction
To return from a function you use the command "Return [returnValue]". You cannot use just "return", but must always return a value. Edit: but you don't actually need a return-command if you don't want to return a value. A function can return all basic data type values, so there are no specific return types for ints, floats etc.
A parameter for a function can be only a primitive data type. For example, you can't put an array as a parameter (this will most likely change in the upcoming coolbasic, at least I truly hope so). The same goes for returning a value.
To include a file you simply use the command 'Include "filepath"'. If the compiler complains, most likely the path is incorrect. With unsaved code the path root (for relative paths) is the Coolbasic-folder. For saved files and exes the root is where the source or exe is. The include command only includes a separate .cb-source file, and it's of course really useful, but not mandatory. You can write all your code to a single file if you want.