Qbasic program/question

Discussion in 'Programmer's Corner' started by n9xv, Apr 28, 2005.

  1. n9xv

    Thread Starter Senior Member

    Jan 18, 2005
    329
    1
    The attachment below is a program I wrote in Qbasic. It calculates dB loss of some popular coaxial feedlines used in RF/2-way radio work. The program does everything ok, but I had origionally planed to have many more feedlines besides the ones shown. At some point I get the error message "out of stack space". My interpretation of the message is that the stack pointer is out of memory space. I'll admit that my routines are probably to simple for what I'm trying to accomplish. Maybe too many embeded routines? Maybe not enough caffeen durring program construction!

    Anyway, take a look if you please and feel free to slice & dice and shoot it down etc. etc. I'm just curious if I can have more choices and avoid the "stack space" issue. Many of my programs follow a similar scheme and I would benefit from any of your all's expertise.

    The .EXE is the larger file, and the .BAS is the smaller file.
     
  2. pebe

    AAC Fanatic!

    Oct 11, 2004
    628
    3
    I've had a look at your program and spotted the fault. Towards the end of the program you have GOSUB CXFDLATTIN. That label is the start of the program so your instruction should have been a GOTO.

    Each time you looped through the program the GOSUB would store the return address on the stack, but there was no RETURN statement so you were getting nested subroutines which led to a stack overflow.

    I think your program could have benefitted from dupliccated parts being written as sub-programs. Shall I have a go?
     
  3. pebe

    AAC Fanatic!

    Oct 11, 2004
    628
    3

    Here they are. Modified and shortened.
     
  4. n9xv

    Thread Starter Senior Member

    Jan 18, 2005
    329
    1
    Exellent work pebe! I remember thinking about using read & data statements way back when but for some reason I chickened out. At one point I actually had a menu/item selection screen that would give many options including the cable loss routine. My idea was to have the whole enchelada available from one menu screen. But with those long nested routines - - - well, it never became a reallity. By all means if you wanna try something, go ahead! I sincerely appriciate the effort. I'm almost embarassed how easy that program could/should have been.
     
  5. pebe

    AAC Fanatic!

    Oct 11, 2004
    628
    3
    I've just tried the download myself. Oops! I assembled the .exe as requiring BRUN45 instead of a standalone .exe

    In case anyone else has tried the .exe and it doesn't work, here is an update (hope I've got it right this time!).

    Re the program mods, if you want to increase the selections just redimension the array. If you've got a lot of data then you could read it in from a sequential file.

    It's nice to get back to a bit of programming!
     
Loading...