Computer Science Canada Exporting From For Loops |
Author: | Anonymous [ Fri Jun 02, 2006 10:46 pm ] | ||
Post subject: | Exporting From For Loops | ||
In one of my modules, I have it export var all, but it doesn't export what is modified in my for loop. My teacher reminded me that everything in a for loop is only seen in the for loop. How do I send data from my for loop outside of the for loop.
How am I able to export this? In my main program it gives me 4 errors: "VAHN_DIR_(direction)_1" is not in the export list of 'Characters'" |
Author: | [Gandalf] [ Fri Jun 02, 2006 11:21 pm ] |
Post subject: | |
Exporting all will only export the variables in the whole scope of the module. As your teacher said, the variables in the for loop only exist there, not within the whole module, so they do not get exported. To include them with all you must declare them outside the for loop as you have done with VAHN_BATTLE, and initialize them inside it. Your usage of the module is not great either... You are using it to compartmentalize your code, which could be done with a procedure. Your module should contain procedures (and functions), some of which will be exported to allow access of the module from the outside world. |
Author: | Anonymous [ Sat Jun 03, 2006 11:03 am ] |
Post subject: | |
Well I learned Modules recently, so I tried to organize my code. Really, there was no need for me to add modules at all, but when I hand it in for my ISU im hoping to get a good mark for using them. I'm not sure if the teacher uses modules, so that's a good sign =) |