SUBSIM Radio Room Forums



SUBSIM: The Web's #1 resource for all submarine & naval simulations since 1997

Go Back   SUBSIM Radio Room Forums > Silent Hunter 3 - 4 - 5 > SH4 Mods Workshop
Forget password? Reset here

Reply
 
Thread Tools Display Modes
Old 10-10-13, 08:23 AM   #1
JoeCorrado
Weps
 
Join Date: Apr 2005
Location: Illinois
Posts: 366
Downloads: 176
Uploads: 5
Default

You could add a few lines of code to output the values received by the program. That would at least tell you if the issue is within the programs functions/processes itself, or if the issue is an error in passing the values to the program. If the values being passed to the program are correct, I would then output the results of each calculation done internally at each step in an attempt to nail down exactly where the errors are being introduced. Does your program establish protected (reserved) memory space upon start up? Most languages will take care of this for you, but I am not familiar with Liberty Basic and it has been a while since I have played with code in any language for that matter. Debugging should be easy enough in any case. Solving the issue after you identify it specifically, well- that can be a whole new type of fun. LOL
__________________
=============



My Game starts with GFO - Keepin' it real as it needs to be!
JoeCorrado is offline   Reply With Quote
Old 10-10-13, 10:19 PM   #2
TorpX
Silent Hunter
 
Join Date: Sep 2010
Posts: 3,969
Downloads: 153
Uploads: 11
Default

Quote:
Originally Posted by JoeCorrado View Post
Does your program establish protected (reserved) memory space upon start up?
I don't really know the details of how this works. I had assumed that this was done automatically by the program language itself. If it doesn't, or fails for some reason, I wouldn't know what to do about it.

Quote:
You could add a few lines of code to output the values received by the program. That would at least tell you if the issue is within the programs functions/processes itself, or if the issue is an error in passing the values to the program.
This is a good idea. I more or less assumed that it was one or more math steps that were going wrong.

I was thinking of putting in a feature where you could test it by having a sample problem run and the results checked, automatically. One can do the same thing manually, but this would save time and at least tell you if things are good to go.


Quote:
Solving the issue after you identify it specifically, well- that can be a whole new type of fun. LOL
Yeah, I know what you mean.



I don't feel as bad about it now. I made 7 more "test shots", being sure to start the program after SH4. All were successful, except one where the graphical sketch was wrong. (The numbers checked out ok. I'm not sure what happened on this one.)


Anyway, thanks for responding, Joe and Nisgeis.
TorpX is offline   Reply With Quote
Old 10-11-13, 08:26 PM   #3
TorpX
Silent Hunter
 
Join Date: Sep 2010
Posts: 3,969
Downloads: 153
Uploads: 11
Default

Ok, I've played around with this some more and I believe I'm zeroing in on the problem(s).

I put in a number of additional lines of code, as per Joe's suggestion to see readouts of all the input variables. There is a text window I use for this sort of thing, so I just had to add the additional variables. Most of the variables are input to the program for each calculation cycle, but some are stored in a file since there is no need to change them most of the time.


There are half a dozen related to torpedo details, tube distance, torp reach, turning radius, etc. I found that when the program malfunctions, the value of r, the turning radius, changes from 310 to 1. These values are stored in a file, and shouldn't change in the program unless you deliberately change them. The others don't change, so why would r change? Beats me.


Even more interesting is that I found out, that it is not the game SH4 that is the cause, but the way I was handling the windows. Normally, when I start this program, I have the editor window, another program window (engine window?), the main window, a text window, and sometimes either a auxiliary window or graphical window. With this gaggle of windows, and SH4 going, I would minimize most or all of these, to reduce the clutter. This seems to be what is "breaking" the program. I can minimize all but the main window. When I do that, any further calculations using r, will be in error. Closing the program and restarting is required to fix it.


There seems to be a separate problem with the graphical window. It will work ok, unless I use the aux. window for a calculation first. Then the sketch will be messed up. I suspect one or more functions in the aux. calculations are overwriting some of the graphical variables. There are a larger number of these, so I will have to go through them and see.


Anyway, the principle problem is the minimizing of the main window. I didn't think this changed the way a computer program works, but apparently it does. I can open another window over it, but I can't minimize it without problems.





TorpX is offline   Reply With Quote
Old 10-12-13, 09:55 PM   #4
TorpX
Silent Hunter
 
Join Date: Sep 2010
Posts: 3,969
Downloads: 153
Uploads: 11
Default

Another update:

I changed the turning radius variable from r to rp, and that seems to have fixed the problem. Do computers dislike short variable names? There are other variables with one letter and they are ok. Oh well.

The problem with the sketch window was unrealated. There is an auxiliary window that is used for different calculations. Some are related to the solution, some are entirely seperate. A couple of these functions used the Abg (angle, bearing) variable and would overwrite the value that the sketch function used. This would mess up the sketch when it was done after the aforementioned aux. functions. I renamed the variables to fix this.

After banging my head against the wall, I feel almost euphoric now.
TorpX is offline   Reply With Quote
Old 10-12-13, 11:09 PM   #5
JoeCorrado
Weps
 
Join Date: Apr 2005
Location: Illinois
Posts: 366
Downloads: 176
Uploads: 5
Default

LOL - computers can be tough to communicate with sometimes. They always have to have things their own way for some reason. I am happy that you tamed the beast!

When I was programming, I always used a naming convention for variable types to help me keep track of them all- something I learned way back when cutting my teeth using Q-Basic. Helps with debugging.

In my experience, single character variable names should be avoided, but hey- it's all just part of the fun!
__________________
=============



My Game starts with GFO - Keepin' it real as it needs to be!
JoeCorrado is offline   Reply With Quote
Old 10-12-13, 11:20 PM   #6
TorpX
Silent Hunter
 
Join Date: Sep 2010
Posts: 3,969
Downloads: 153
Uploads: 11
Default

Quote:
Originally Posted by JoeCorrado View Post
LOL - computers can be tough to communicate with sometimes. They always have to have things their own way for some reason. I am happy that you tamed the beast!
So true.
TorpX is offline   Reply With Quote
Old 10-13-13, 04:30 PM   #7
Pisces
Silent Hunter
 
Join Date: Dec 2004
Location: AN9771
Posts: 4,839
Downloads: 309
Uploads: 0
Default

While I don't know anything about Liberty Basic, programing languages usually have a very similar syntax....

We might be of some better assistance if we can view the source code. Otherwise we're just shooting in the dark. And my magic orb is undergoing maintenance.

What JoeCorrado said: output every calculation step or variable change. Including your own input given to the program. Preferably saved into a log file for future reference.
Pisces is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 12:09 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Copyright © 1995- 2026 Subsim®
"Subsim" is a registered trademark, all rights reserved.