Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    2 Star Lounger
    Join Date
    May 2008
    Location
    Jacksonville, Florida, USA
    Posts
    142
    Thanks
    52
    Thanked 0 Times in 0 Posts

    Unhappy QBasic program problem

    I still use an old DOS program-creating application called QBasic.
    I recently had to update one of the programs I use, but when I tested
    it when I considered it updated, it gave me a couple problems that for the
    life of me I cannot figure out why, and what remedy needs to be used to
    get the updated program to work again without an error.
    It has to do with a SELECT CASE code series. I have an input file of certain
    dollar values that I post into an Array and into individual variables. The
    Select Case code lines, for the most part, work. I have a CASE ELSE statement
    at the end of two of the CASE segments that end the program if "bad input"
    figures are encountered.
    I searched diligently for why this was occurring, but I was sure the input data
    used was good and should have passed muster. After not being able to find out
    the cause, I commented out the two CASE ELSE lines of code. Now the program
    works like I expected. I don't feel like I am likely to include any input data that
    won't be acceptable, so I am not concerned about having commented out these
    two lines of code. I just feel like every contingency should be programed for.
    Can any QBasic adept lounger give me a clue on why this is happening.

    flavet
    Dell Inspiron 15R, 8GB, Win7 Home Premium 64bit SP1
    All help truly appreciated!

  2. #2
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,168
    Thanks
    47
    Thanked 978 Times in 908 Posts
    I haven't seen Qbasic in use for about 20 years and have long forgotten the syntax.
    Can you post the problematic lines and we will see if the dinosaurs come out. ;-0)

    cheers, Paul

  3. #3
    2 Star Lounger
    Join Date
    May 2008
    Location
    Jacksonville, Florida, USA
    Posts
    142
    Thanks
    52
    Thanked 0 Times in 0 Posts
    Paul,

    Sorry to take so long to reply, but I am not very well versed in using this forum. I searched through the help items on how to attach a segment of program code for you to view, but the best I could find was an item about making a file and then clicking on a paperclip icon.

    Here is some of the code from the QBasic program I am having trouble with. It starts with 2 lines of comments and goes to the CLOSE statement.
    I did a copy & paste process to acquire the code you see. I'm not sure how much you can get from seeing this, but let me describe what the input
    statements consist of:
    Here is a sample line of text that you might see in the input file:
    12,A, 17850 ,maximum income 1st tax bracket
    The first two char's are an 'Item ID Prefix", the next one char is an 'Item ID Suffix', the third field is a dollar amount, and the final field is a comment field.
    Each item is separated by a comma. The first three fields are used by the program, but the fourth is not, it is merely a remark for me to know what the line is.

    The CASE 12 items and the CASE 10 segments are the ones giving me the problem. See the single apostrophy char on the two CASE ELSE statements in
    the two Cases. That means to the program interpreter that those lines are commented out.
    Hope you are able to make sense out this without being able to see the entire program listing, or a least more of the details related to this code segment.

    Here are the program code lines:
    'acquire tax-year's constant & certain variable data from stored file
    'also value certain array elements & other variables
    s.ifile.1 = s.fnmprefx + s.tax.yr + "CNST.DAT"
    OPEN s.ifile.1 FOR INPUT AS #1
    DO UNTIL EOF(1)
    INPUT #1, i.idp, s.ids, l.value, s.remark
    SELECT CASE i.idp
    CASE 12
    SELECT CASE s.ids 'value array2 elements
    CASE "A": l.array2(2, 1) = l.value 'tax bracket max inc figs
    CASE "B": l.array2(3, 1) = l.value
    CASE "C": l.array2(4, 1) = l.value
    CASE "D": l.array2(5, 1) = l.value
    CASE "E": l.array2(6, 1) = l.value
    CASE "F": l.array2(7, 1) = l.value
    CASE "G": l.array2(8, 1) = l.value
    CASE "K": l.array2(2, 2) = l.value 'tax bracket min tax figs
    CASE "L": l.array2(3, 2) = l.value
    CASE "M": l.array2(4, 2) = l.value
    CASE "N": l.array2(5, 2) = l.value
    CASE "O": l.array2(6, 2) = l.value
    CASE "p": l.array2(7, 2) = l.value
    CASE "S": l.array2(1, 3) = l.value 'tax bracket tax rates
    CASE "T": l.array2(2, 3) = l.value
    CASE "U": l.array2(3, 3) = l.value
    CASE "V": l.array2(4, 3) = l.value
    CASE "W": l.array2(5, 3) = l.value
    CASE "X": l.array2(6, 3) = l.value
    CASE "Y": l.array2(7, 3) = l.value
    ' CASE ELSE: PRINT "Bad tax rate data, abending": CLOSE : END
    END SELECT
    CASE 1, 2, 15, 22: l.array1(i.idp, VAL(s.ids)) = l.value
    'N O T E - array1 rows 4-6 store tax payment amounts
    CASE 61, 62: l.array1(i.idp - 57, VAL(s.ids)) = l.value
    CASE 10
    SELECT CASE s.ids
    CASE "A": l.xmptrte1 = l.value
    CASE "B": l.trigger1 = l.value
    CASE "C": l.xmptions = l.value
    CASE "D": l.trigger2 = l.value
    CASE "E": l.xmptrte2 = l.value
    CASE "F": l.divisor1 = l.value
    CASE "G": l.percent1 = l.value
    ' CASE ELSE: PRINT "Bad exemption data, abending": CLOSE : END
    END SELECT
    CASE 18
    SELECT CASE s.ids
    CASE "A": l.trigger3 = l.value
    CASE "B": l.percent2 = l.value
    CASE ELSE: PRINT "Bad net investment data, abending": CLOSE : END
    END SELECT
    CASE 7: FOR i = 1 TO i.prd: l.array1(i.idp, i) = l.value: NEXT
    CASE 34, 35: l.array7(i.idp - 33, VAL(s.ids)) = l.value
    CASE 41, 42: l.arrayC(i.idp - 40, VAL(s.ids)) = l.value: CG = true
    CASE 51: l.arrayD(1, VAL(s.ids)) = l.value
    CASE 52: l.arrayE(1, VAL(s.ids)) = l.value
    CASE 70: l.pytax = l.value
    END SELECT
    LOOP
    CLOSE

    Edit Post comment: I notice that all the lines of code have been rearranged to left align the text. The program lines are nicely indented.
    Last edited by flavet; 2013-06-23 at 16:45. Reason: Lines of text have been rearranged.

  4. #4
    WS Lounge VIP access-mdb's Avatar
    Join Date
    Dec 2009
    Location
    Oxfordshire, UK
    Posts
    1,721
    Thanks
    146
    Thanked 156 Times in 149 Posts
    Just looked at my QBasic files from 1995, phew! I even used CASE as well, but can't remember in detail how they work. However, in e.g. VBA (Visual Basic for Access) there is an option to step through the program and inspect values as you go. Is there not such an option with QBasic? This is how I debug VBA. I note you don't say what the error is - or at least I can't see it if you do. Can you say what error messages are generated?

    Just Googled and there appears to be a Qbasic compiler - see http://www.softpedia.com/get/Program...s/Qbasic.shtml, which has a debug option.
    Last edited by access-mdb; 2013-06-23 at 17:58.

  5. The Following User Says Thank You to access-mdb For This Useful Post:

    flavet (2013-06-27)

  6. #5
    2 Star Lounger
    Join Date
    May 2008
    Location
    Jacksonville, Florida, USA
    Posts
    142
    Thanks
    52
    Thanked 0 Times in 0 Posts
    Thank you, access-mdb,

    I will check out the link you posted later, but let me answer your questions first. I believe that you can single step through QBasic, but I have never had to employ that facility. Please note that my code requires that if QBasic runs into data it finds unacceptable for reasons only known by it, I have built in the CASE ELSE statement that the program should end at that point. Since QB does not give a clue as to what it finds unacceptable the programmer is left to try to figure out why on his own. I have always been successful in finding what my code errors have been, but this time I am stumped. This program worked for years for me but I had to do some updates because of changing rules by the IRS. I had to add one additional CASE detail statement to each those two CASE ## items. Then I needed to add an additional row to the dimensioning specification. That has always been a gripe of mine - can't find out the underlying problem; it just says there is a problem so fix it. I am sure that there may be an error message that is generated, but it usually does not provide any why.
    Because I commented out the two CASE ELSE statements the program now works and it works correctly. So whatever QBasic does not like does not seem to be something I need be concerned with. I would like to find out what the underlying problem is but if I can't, so be it.

  7. #6
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,168
    Thanks
    47
    Thanked 978 Times in 908 Posts
    I can't see why the CASE ELSE statements should cause problems, except that they terminate the file read unexpectedly.
    From your code it seems the program exits if the 'Item ID Suffix' is either H, I, J, Q, R, Z or a non letter. I'd create a test file that doesn't cause an exception and test with the CASE ELSE lines in place.

    p.s. The icons at the top of the edit window allow you to post special text. Use the key word CODE for code posts.
    Code:
    SELECT CASE i.idp
    	CASE 12
    		SELECT CASE s.ids 'value array2 elements
    			CASE "A": l.array2(2, 1) = l.value 'tax bracket max inc figs

  8. The Following User Says Thank You to Paul T For This Useful Post:

    flavet (2013-06-27)

  9. #7
    2 Star Lounger
    Join Date
    May 2008
    Location
    Jacksonville, Florida, USA
    Posts
    142
    Thanks
    52
    Thanked 0 Times in 0 Posts
    CALL OFF THE CAVALRY! I decided to retest the latest version of my program (the one that did not work because of two CASE ELSE statements, that I commented out in order to allow the program to go to a good end.). I opened it and decided I wanted to see exactly what error message the program had given me originally. So I uncommented the two offending statements and restarted the program. Lo and behold, today it worked as I originally wanted it to work. I don't know why, but I am not going to brood over it. I am just going to be happy with the way it is working.

    So I want to thank those who replied to my post. For access-mdb: I went to the software site and read what I could about what they offered. I may download it someday. Thanks.

    flavet

    oops - while previewing this reply I noticed, Paul, your latest posting. As I said above for some reason the program decided to work without any further updating. Thank you for your interest in my problem, and your suggestions.

  10. #8
    New Lounger
    Join Date
    Jun 2010
    Location
    Brisbane, QLD Australia
    Posts
    14
    Thanks
    0
    Thanked 1 Time in 1 Post
    In case the problem comes back, I'd just like to point out that in the code you provided, the case 12 is doing a check on lower case 'p', not upper case 'P'. All the other data checks are on upper case, so I would assume that this probably should be as well. If you have data with upper case P, that will fall through to the case else and end the program unexpectedly.

  11. The Following User Says Thank You to DancingFool For This Useful Post:

    flavet (2013-06-27)

  12. #9
    2 Star Lounger
    Join Date
    May 2008
    Location
    Jacksonville, Florida, USA
    Posts
    142
    Thanks
    52
    Thanked 0 Times in 0 Posts
    Dancing - great catch! These tired old 83 year old eyes just don't cut the mustered anymore. The reason why the original problem seemed to go away is because I was not using input files that included the Case P data. That was part of the updates I had to add, but which were outside the range of the input data.
    Regardless, great catch because I would have needed to have the correct 'case' (upper) for the CASE when I correlate the actual input data at a later time this year. I went back and updated this item, so now that will not be a problem in the future.
    Thank you.
    Dell Inspiron 15R, 8GB, Win7 Home Premium 64bit SP1
    All help truly appreciated!

  13. #10
    New Lounger
    Join Date
    Dec 2009
    Location
    Norfolk, UK
    Posts
    2
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Hello flavet
    Good to see good old QBasic still in general use. We still have quite a number of programs here, originally written in Quickbasic, but now I have made use of FreeBasic which is a great version of BASIC, compatible with QBasic, but will produce executables. It does also have a companion IDE called fbide which can be downloaded with the compiler. I would thoroughly recommend it. FreeBasic does also expand on the functionality of QBasic so is well worth looking at.
    Regards
    RV

  14. The Following User Says Thank You to robV For This Useful Post:

    flavet (2013-06-27)

  15. #11
    2 Star Lounger
    Join Date
    May 2008
    Location
    Jacksonville, Florida, USA
    Posts
    142
    Thanks
    52
    Thanked 0 Times in 0 Posts
    robV - thanks for your reply. I am not as skilled in a lot of the underlying structure as I would like to be. I have been retired for 21 years and away from any programming except for my own use. I seem to recall that program creation involved things like compilers and interpreters. I felt pushed to get the job done and don't bother 'us' with your questions. When I find something that works I may use it, and not investigate what it takes to make it work beyond the obvious. I don't even recall the term IDE, and when I tried searching for a definition on google it said no matches found.
    I don't plan on moving into anything different at my age, I will just keep using what I know. I do thank you for your reply; it was very interesting to know that so much is out there for the asking.
    Best wishes, flavet

  16. #12
    Star Lounger burger2227's Avatar
    Join Date
    Feb 2013
    Location
    Pittsburgh
    Posts
    81
    Thanks
    2
    Thanked 1 Time in 1 Post
    Quote Originally Posted by Paul T View Post
    I haven't seen Qbasic in use for about 20 years and have long forgotten the syntax.
    Can you post the problematic lines and we will see if the dinosaurs come out. ;-0)

    cheers, Paul
    The Dinosaurs are here: QB64 is a FREE QBasic compiler for 64 bit WIN, MAC and LINUX : www.QB64.net

    Contrary to popular beliefs, QB64 offers everything that a C compiler can do. If you haven't seen Qbasic being used in 20 years then you gave it up only 2 years after it was last released...

    Your code problem was most likely a file read error or the lack of UCASE$ or LCASE$ when checking strings.
    Last edited by burger2227; 2013-06-27 at 09:50.

  17. The Following User Says Thank You to burger2227 For This Useful Post:

    flavet (2013-06-27)

  18. #13
    New Lounger
    Join Date
    Dec 2009
    Posts
    8
    Thanks
    0
    Thanked 1 Time in 1 Post
    Don't forget the old stand by method where you print the value of the variable before the CASE statement followed by an input statement. This effectively prints the value in question and stops execution of the program while it waits for some type of entry. 'The old fashioned approach to debugging '.

  19. The Following User Says Thank You to ruler For This Useful Post:

    flavet (2013-06-27)

  20. #14
    2 Star Lounger
    Join Date
    May 2008
    Location
    Jacksonville, Florida, USA
    Posts
    142
    Thanks
    52
    Thanked 0 Times in 0 Posts

    QBasic program problem

    Thanks to one and all that have replied to my original post. I don't always understand what is being said in the replies, but if I wanted to know anything I ask what is meant.
    I have used various self-created QBasic programs for my own use (regularly) and they always satisfy my needs. If, when I am creating or updating a program of this type and I make a logic error or a syntax error I have always been able to correct the problem when I test the program. I will be sticking with the software I have been using until it no longer works, or until I no longer work.
    Thanks everyone.
    Dell Inspiron 15R, 8GB, Win7 Home Premium 64bit SP1
    All help truly appreciated!

  21. #15
    New Lounger
    Join Date
    Jan 2012
    Location
    Sundridge, ON, CA
    Posts
    14
    Thanks
    2
    Thanked 2 Times in 2 Posts
    @flavet - good for you.

    I noticed nobody gave you a definition for IDE. If you still haven't found it yourself, it means Integrated Development Environment and what that means is that it allows you to edit code in an editor that will colour highlight your code based on what kind a of coding thing it is (example: variables will be a different colour than keywords). But wait - that's not all you get ... usually an IDE will also show you syntax errors while you type the code - you don't need to run it first (this might be the biggest reason to use an IDE). Sometimes they can offer suggestions to fix the error. They also often offer auto-completion. When you start typing something they offer possible completions to whatever you just typed. Usually they allow you to "debug" code by letting you execute it one line at a time, or all the lines up to a certain point, view the values of variables while the program is paused, etc.

    Anyway, as you say - if you are happy then no need to change. Some IDEs are pretty easy to learn, others can have real learning curve.

    Jim

  22. The Following User Says Thank You to JavaJim For This Useful Post:

    flavet (2013-06-27)

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •