Computer Science Canada Problem with files |
Author: | s3arkay [ Fri Jun 16, 2006 8:04 pm ] |
Post subject: | Problem with files |
Here is my problem guys: I made a program which lets you enter student names, marks, age, sex ect. My program has to add users, edit users, sort and search. So when I go to create a newuser I have GUI.Quit in the procedure. when I take this out of the procedure the information does NOT get writen into the text file. It stays in while the program is running but when I close everything down it will not come back (never put into my file) So i keep the GUI.Quit in the procedure so it will write to the file. But the problem is, my buttons only work once and I want to be able to click them more then once. Understand? Please help |
Author: | s3arkay [ Fri Jun 16, 2006 8:05 pm ] | ||
Post subject: | |||
The h:/ are the pictures from my usb |
Author: | Bored [ Fri Jun 16, 2006 9:21 pm ] | ||||||||||||||||
Post subject: | |||||||||||||||||
That's the problem, your call GUI.Quit and from then on your loop will call GUI.ProcessEvent and exit. The simple solution to this is to call GUI.ResetQuit. Take this
to
This will undo what GUI.Quit does and will also reloop the code. Aswell you may want to take a look at this
First off you never want to hard code the length of the array, you want to use Flexible arrays which will allow you to add another element for each name in the file. Aswell you do not want to have the number of names at the top, what if someone changes that, or the program miscounts do to a logic error. You then cannot run the program proberply. Insetad you should look up eof() which returns true if the end of a file is reached. your could then replace, exit when
Third thing, if you are going to do it this way, why not have a for loop. You could instead have
But you shouldn't do that but instead look into flexible arrays and eof(). Oh yes one more thing, DO NOT use global variables. clas is a global variable, instead pass it to each procedure as a parameter. You can pass an entire array as a parameter, for example.
Now you may be thinking, i want to edit my elements, well that's where the var command comes into play
|
Author: | s3arkay [ Fri Jun 16, 2006 10:34 pm ] |
Post subject: | |
Dude.... Bored, I owe you big time. Thanks for all the help and you saved my life it seems lol... Thanks man, appreciate it |
Author: | s3arkay [ Sat Jun 17, 2006 8:32 am ] |
Post subject: | |
One problem Bored, my version of turing doesnt have ResetQuit. i have 4.0.3 |
Author: | Bored [ Sat Jun 17, 2006 9:18 pm ] | ||||||
Post subject: | |||||||
Well then create one, it's rather simple. All GUI.Quit does is change the variable is call the procedure WidgetModule.Quit, the procedure WidgetModule.Quit is change the variable quit to true. So to reverse this we simply have to change it back to false. The first step is to locate your turing directory. This is most likely under "C:\Program Files\Turing". From there you would find the file gui, which is the code for the gui module. This is under "Turing\Support\lib". So once in there you must create the ResetQuit procedure. The code for this is simply
Now we need to export it, so go to the top and you'll find a big list of procedrues being exported, I'd suggest you use CTRL - F to search for Quit and place ResetQuit beside it for neatness sake. Now that we have our GUI.ResetQuit, we need to create the WidgetModule.ResetQuit. To do this open WidgetModule.tu under "Turing\Support\lib\GUIClass". Do the same procedure as above but replace the line
with
|