|
Post by qwertyiou on May 12, 2021 17:28:02 GMT 1
Hi, I just joined GB32 but I have been coding GFA most days for 30 years but nearly all in DOS after starting on an Atari ST. I am now thinking of moving to Windows. If I do, I have lots of programs to convert but it will be a lot of work. Is there a way to find unused variables, arrays and procedures in my DOS programs to reduce my task. After loading into GB32 I would have thought that Cleanup Resources would work but it seems to do nothing. Any suggestions most welcome.
|
|
webu
Full Member
Posts: 149
|
Post by webu on May 12, 2021 17:34:14 GMT 1
This is not so difficult, because GB32 complains, if you want to use variables, which are not declared. Start with small programs, then you already get experience.
|
|
|
Post by qwertyiou on May 12, 2021 19:34:29 GMT 1
Thanks webu, However, that is part of the problem. I have dozens of programs with thousands of lines. DOS just assumes that every variable is Global and did not even have a command called Global. So I have to go though and add every variable to a Global command. A large proportion of the variables are never used, so it would save me a lot of time if I could eliminate them, which would be good anyway. I have a vague memory of a program that did this twenty years ago, possibly when I looked at an early version of GFA for windows. Mick
|
|
webu
Full Member
Posts: 149
|
Post by webu on May 12, 2021 20:38:17 GMT 1
Do not spend time for searching of unused VARs. What is the problem with them? Memory?
|
|
|
Post by qwertyiou on May 12, 2021 21:53:36 GMT 1
It is mainly that I am going to have to add thousands of them to Global commands so it seems like a good opportunity if there is a way to eliminate the junk. The other main issue is that I am often digging out and working on these large long-forgotten 20 year old programs and the more unused variables and procedures I can eliminate the easier that task will be. I have just had a thought on it: If i cannot find a specialist program or app, I guess I may be able to do a partial job with one which that does not need to have anything to do with GFA or coding at all. I may be able to do it with a program which counts words in a text. A smart one may work on a GFA LST file.
|
|
|
Post by qwertyiou on May 13, 2021 12:51:54 GMT 1
At the time I made this inquiry I also emailed it to Sjouke Hamstra. He told me about the command Auto. That automatically generates Global commands for all variables (but not arrays). That solves part of the problem very well.
|
|
|
Post by (X) on May 14, 2021 12:56:35 GMT 1
I assume that, in GFA for DOS, you never needed to declare a variable type with a Dim, Global, Local, Private, Public or Static command.
I don't know of any "built-in" way of doing this, but, here is my idea for doing it on your own.
1) The TRON TROFF commands may be of use. You could write code to output each line used by the program to a text file. This would at least tell you which lines are being used.
2) You could write code to generate a sorted list of unique variables names* from the "TonTroffOutput.txt" file. (*By looking at the string that precedes each '=' sign.) 3) If you do the same as above for the original '.LST" file, you would have a complete list of all the variables names in your code. 4) The difference would give you your answer.
|
|
|
Post by qwertyiou on May 17, 2021 3:28:39 GMT 1
Thanks X-man, Yes, in DOS and on the Atari you only needed to DIM arrays. In later versions of DOS GFA it would warn you if you introduced a new variable. Apart from that it was a free for all: you could also use practically any variable name whether it was the same as an array, procedure or command name. Having done that a lot, it is creating a lot of work for me now. I just managed to get a 2200 line DOS GFA program transferred and working but It took me about 40 hours work Since Sjouke told me of the Auto command, unused variables are not very important, as webu suggested. But I may test the Tron and Troff approach with other programs. Before I heard about Auto I decided to work out which variables were unique in the following way. I converted nearly all symbols into commas in a LST file using a text editor then I loaded this as a comma separated value (CSV) file into one column of MS Excel and sorted it into alphabetical order. I then had about 7,000 alphabetical variable names/commands/words and I went through all of them looking for ones that were unique. I deleted almost 200 unused variables and about 500 lines of code, but it was intensely time-consuming and probably not worth it, although I did find a couple of minor bugs as well. I am sure there is word counter software which would list how many times words are mentioned but the only one I looked at did not give the number of occurrences.
In transferring the shrunk program, I nearly gave up on GB32 because it was crashing every minute. But now it seems much more stable. I think I will write any new programs in GB32 but I have some much larger and more complicated programs that I fear I would not be able to convert without hundreds of hours of work. So I will probably have to keep working with DOS. Mick
|
|
|
Post by (X) on May 17, 2021 13:06:47 GMT 1
Just out of curiosity, what do your programs do?
|
|
|
Post by qwertyiou on May 17, 2021 23:59:03 GMT 1
They mainly look for links between large downloadable data files from the internet. The program I am working on converting to GB32 at present is one that downloads geomagnetic data, which are timed variations in the earth's magnetic field due to solar interference. That is very typical of the files I use.
I have worked out one reason why GB32 was crashing so much. I had "auto complete word" turned on and that would crash the whole system while I simply tried to type a variable in. Now that I have turned that off it very rarely crashes like that. My other problem was that it would get locked into compiling or running a program and I did not know how to stop it, so I would have to crash out and lose recent code. Is there a way to stop it? In DOS you just had to press Ctrl, Alt & Shift together.
|
|
|
Post by (X) on May 18, 2021 13:39:13 GMT 1
How to stop an unresponsive program... To handle errors "in-code"...
A few tips...
|
|
|
Post by (X) on May 19, 2021 4:44:25 GMT 1
Another clue is:
The Gfa_Vars collection object represents all or part of the variables used in an application.
|
|
|
Post by qwertyiou on May 20, 2021 0:35:44 GMT 1
Thanks for these ideas. I will report back on them when I find the time to investigate them
|
|
|
Post by (X) on May 20, 2021 21:31:33 GMT 1
There is a GFA Debug Icon - usually in the lower right section - in the Window's Toolbar. If you right-click on it, you can show or hide the debug output window, pause, step, follow, continue and stop a non-compiled running program (F5).
Although this feature may be helpful, it is not the only way to troubleshoot/debug a program.
I usually get by with a "Try .. Catch .. EndCatch" wrap around troublesome code.
|
|
|
Post by (X) on May 20, 2021 23:19:16 GMT 1
My other problem was that it would get locked into compiling or running a program and I did not know how to stop it, so I would have to crash out and lose recent code. Is there a way to stop it? In DOS you just had to press Ctrl, Alt & Shift together.
Use Ctrl-Break to stop an unresponsive non-compiled application started from the IDE. (Usually started by pressing F5).
Use Task Manager to stop an unresponsive compiled application.
|
|
|
Post by scalion on May 30, 2021 11:17:10 GMT 1
Hi, Dont forget to insert peekevent or sleep in loop in your program if want can break execution. If you forget it There is a last-ditch solution to interrupt the program and regain control of the code. While your program is blocked and unresponsive click on the taskbar and bring the code back to the top of windows. At this moment try CTRL + ALT + PAUSE, if you have a little luck it works, and save your code in the process !!!
|
|
|
Post by qwertyiou on Jun 3, 2021 16:40:16 GMT 1
I have worked out one reason why GB32 was crashing so much. I had "auto complete word" turned on and that would crash the whole system while I simply tried to type a variable in. I sent a copy of a program that was crashing with Auto Complete Word to Sjouke Hamstra. He worked out that it was because I was using Option Base 1 and he sent me a new gll file which has now fixed that bug. I hope to be addressing the other issues in a few days time. Mick
|
|
|
Post by qwertyiou on Jun 10, 2021 18:33:29 GMT 1
How to stop an unresponsive program...
|
|
|
Post by qwertyiou on Jun 11, 2021 12:37:35 GMT 1
Thanks for these x-man. I have been testing them out. They do not stop the programs locking while apparently compiling but will be useful along with On Error GoTo next time I have a bug on an imported program. Mick
|
|
|
Post by qwertyiou on Jun 12, 2021 11:22:55 GMT 1
Thanks x-man, I have looked at each of these and they all seem useful. I still have a program that hangs when I try and load it because it goes straight to compiling but t is not a serious problem. Mick
|
|
|
Post by qwertyiou on Jun 12, 2021 18:17:37 GMT 1
Another clue is: The Gfa_Vars collection object represents all or part of the variables used in an application. A Gfa_Vars collection consists of Gfa_Var items. A Gfa_Var item contains the properties that allow you to get information about the variable like its name, type, location, and value. Thanks x-man, Gfa_Vars would contribute to my original question of how to find unused variables as it allows you to print out all variables which have no value.Mick
|
|
|
Post by qwertyiou on Jun 15, 2021 9:55:18 GMT 1
There is a GFA icon in the Window's Toolbar. If you right-click on it, you can show or hide the debug output window, pause, step, follow, continue and stop a running program. + Ctrl-Break will work to Stop an application if run from the IDE (F5) but not the compiled version. Thanks x-man. However on my Windows 10 laptop I do not get these options coming up if I right click on the GB32 icon. Control and break does stop a program as you say that should be helpful. But it does not stop a program locked while compiling which is the problem I am trying to deal with at the moment
|
|
|
Post by (X) on Jun 15, 2021 13:19:47 GMT 1
Thanks x-man. However on my Windows 10 laptop I do not get these options coming up if I right click on the GB32 icon.
Is this while running a compiled version of your program (the .exe)?
|
|
|
Post by qwertyiou on Jun 16, 2021 0:19:53 GMT 1
Is this while running a compiled version of your program (the .exe)?
Hi x-man, no I have never seen these options. I just tested whether they appear when when a compiled (.exe) program is running and they still do not do so. I have tried right-clicking when the gb32 is running and when gb32 is not running but the icon just pinned to taskbar. I have tried when it is locked trying to compile a program. I have tried when running gb32 as administrator. Every time the only options that come up are to open a new gb32 window or with one of the recently edited programs or to close all gb32 windows or to unpin it from taskbar.
|
|
|
Post by (X) on Jun 16, 2021 12:45:41 GMT 1
Hello Mick,
After going over your posts, I realized that you may have been having problems "while compiling" which I have not addressed directly.
The only suggestion I have for now is to compile your code in sections and by process of elimination, find out where the problem is.
There is always the possibility that the default compiling options are causing the problem.
I usually set and leave those to the default settings.
I amended my previous comment to include the location of the GFA Debug Icon...
|
|
|
Post by qwertyiou on Jul 26, 2021 22:48:51 GMT 1
There is a GFA icon in the Window's Toolbar. If you right-click on it, you can show or hide the debug output window, pause, step, follow, continue and stop a running program.
Thanks x-man. However on my Windows 10 laptop I do not get these options coming up if I right click on the GB32 icon. Hi x-man I have just returned after 6 weeks back using my DOS GFA programs. I have now found the GFA debug icon which was hidden away a bit and so I now have the above options and stop does seem to work. So thank you very much for that and your patience in repeating it until it made sense to me. Mick
|
|
|
Post by qwertyiou on Jul 27, 2021 16:04:19 GMT 1
Hi, Dont forget to insert peekevent or sleep in loop in your program if want can break execution. If you forget it There is a last-ditch solution to interrupt the program and regain control of the code. While your program is blocked and unresponsive click on the taskbar and bring the code back to the top of windows. At this moment try CTRL + ALT + PAUSE, if you have a little luck it works, and save your code in the process !!! Merci Beaucoup for the input Nicolas, The Peekevent type options are a bit beyond me at the moment as I am not used to "messages" when programming. I did try them but did not seem to help. However, it is good to be aware that such things are possible. As for CTRL + ALT + PAUSE no luck yet but I will bear it in mind as it is similar to the CTRL + ALT + SHIFT which is the usual way to stop a program in DOS GFA. Mick
|
|