![]() |
![]() |
Chapter 5: Advanced topics: This section is designed for programmers and advanced users. You can do a lot of advanced programming techniques in DiNGS.
1. Local variables You can define local variables for SUBs or the main loop if you want to keep the SUB seperated from the main code and want to re-use it in some other program once again. You define a local variable within a SUB by using the LOCAL keyword. You can define local numbers, words and array of them like this: LOCAL num, word$, num_array[], word_array$[] To access a global variable that has the same name as a previous defined local variable use the GLOBAL keyword. See the command-reference of these commands for a sample code.
2. Functions and return values Usually DiNGS does not support the feature to create user-defined functions. You can handle this by setting global values like this: var1=1; var2=2
3. Dynamic arrays Yes, DiNGS offers you the ability to re-dim arrays. But you must set the values of the array manually afterwards. sizeof_a=5
4. Freeing Memory Usually it’s not supported to free memory in DiNGS. But you can do this very simple by loading a resource that does not exist. LOADSPRITE “xx”, 0 This will free the memory that was used to store the image of sprite ‘0’. LOADSOUND “xx”, 0, 1 This will free sound number ‘0’ DIM a[0] This will free the memory used for this array.
5. Hexadecimal Numbers You cannot only use decimal numbers, but use the hex-writing, too. ad=127; ah=0xff;
|