Announcement

Collapse
No announcement yet.

erratic behavior--Help!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • erratic behavior--Help!

    My code:
    Code:
    Xcust$=Mid$(customer,540)
    FOR JK& = 34 TO 36:
    J& = INSTR(Xcust$, CHR$(124))
    IF J& > 1 THEN cust(jk&) = LEFT$(Xcust$, J& - 1): Xcust$ = MID$(Xcust$, J& + 1)
    IF J& = 1 THEN Xcust$ = MID$(Xcust$, 2):cust(jk&)=""
    If Len(Xcust$) <2 Then
    cust(jk&) = String$(75," ")
    ELSE
    cust(jk&) = Left$(cust(jk&) & String$(75," "),75)
    END IF
    NEXT
    This fairly simple code has been running flawlessly for several years both on my development computer (Win10Pro) and on customer's Win 7 computers. Still works on theirs, but on mine, choosing the Customer section of the program, the entire screen just disappears. Other menu choices (invoicing, payments, etc.) work. I am using an exact copy of their customer data. The program is loading a table with the entire customer file, and it processes these few lines for each customer. In order to debug, I have inserted print lines followed by waitkey$ after each line so I can see how far it gets with what data. It varies. If I press the enter key after each wait in a slow rhythm, I can get about halfway through loading the 84 customers. If I get impatient and click faster, it bombs sooner. And, as I said initially, without any waitkey$'s, it bombs immediately. Also, I am using the same .bas code originally used to compile theirs (the current working version), but recompiling it on my computer and then running it on their system bombs in same fashion as on my computer. Confused? Me too. Any ideas? It bombs when using PBCC Editor or in old JellyFishPro.

  • #2
    Are you using the current version of CC or an earlier version?
    Was it previously compiled using a different version?

    Do you have
    #DEBUG ERROR ON
    #DEBUG DISPLAY ON

    and error trapping consistently used throughout the application?

    Crashing in different iterations depending on imposed delays suggests that the problem may lie elsewhere and it just manifests itself at this point. Since it has happening during array operations, I'd be looking for an earlier out of bounds error. for a start.

    Comment


    • #3
      FWIW, Stuart's suggestion of #DEBUG DISPLAY ON in conjunction with several labels might be quicker as it will show the last label successfully reached. Your error will be after that point.
      Rod
      I want not 'not', not Knot, not Knott, not Nott, not knot, not naught, not nought, but aught.

      Comment


      • #4
        Now I am really confused. Rodney, I put in #DEBUG ERROR ON and the problem went away! Runs on my computer and on client's. Thank you!

        Comment


        • #5
          I would still be inclined to track it down as adding a delay may hide the issue but its still there. Have a look at using "TRACE ON" in conjunction with labels to narrow down where the problem occurs. I would also look at the data in the event that it has some quirk that triggers a crash and also if the form of that data does not work with the code you have posted.
          hutch at movsd dot com
          The MASM Forum

          www.masm32.com

          Comment


          • #6
            What happens when J& = 0?

            Comment


            • #7
              Originally posted by Jim Fritts View Post
              What happens when J& = 0?
              Really?

              Then XCust$ doesn't get trimmed and Cust(jk&) is filled with spaces.

              Actually I don't think it does what the OP intends.
              Unless cust(j%) is filled earlier with some value then If j& = 0, cust(Jk&) is always 75 spaces.

              I think she needs
              cust(jk&) = Left$(XCust$ & String$(75," "),75)
              as the last asssignment, not
              cust(jk&) = Left$(cust(jk&) & String$(75," "),75)

              Comment


              • #8
                Originally posted by Ellen Reddick View Post
                Now I am really confused. Rodney, I put in #DEBUG ERROR ON and the problem went away! Runs on my computer and on client's. Thank you!
                That's just masking the problem, not solving it. You still need to find the cause, otherwise it is likely to affect your application somewhere else!

                DEBUG ERROR ON adds additional code to your application so the coding error is likely to have a different effect

                Without DEBUG DISPLAY ON, you can still have an error and not know about it.

                Try commenting out none, one and both of the debug lines here and see what happens with an out of bounds error:

                '
                Code:
                #COMPILE EXE
                #DIM ALL
                #DEBUG ERROR ON
                '#debug display on
                
                FUNCTION PBMAIN () AS LONG
                 DIM s(1 TO 3) AS STRING
                  ? s(4)
                  ? "Error passed"
                END FUNCTION
                '
                Note: Compile and run several times. On my machine, commenting out both lines and compiling and running sometimes results in an application that crashes and sometimes runs with no apparent problem,!

                Comment


                • #9
                  Ellen, I don't know anything about #DEBUG ERROR ON from using it, I've always been successful( or thought I was) using #DEBUG DISPLAY ON as this example shows:
                  label1:
                  Xcust$=MID$(customer,540)
                  FOR JK& = 34 TO 36:
                  label2:
                  J& = INSTR(Xcust$, CHR$(124))
                  label3:
                  IF J& > 1 THEN cust(jk&) = LEFT$(Xcust$, J& - 1): Xcust$ = MID$(Xcust$, J& + 1)
                  label4:
                  IF J& = 1 THEN Xcust$ = MID$(Xcust$, 2):cust(jk&)=""
                  label%:
                  IF LEN(Xcust$) <2 THEN
                  cust(jk&) = STRING$(75," ")
                  ELSE
                  cust(jk&) = LEFT$(cust(jk&) & STRING$(75," "),75)
                  END IF
                  NEXT
                  However, I expect that it will return an error somewhere else in your program if it returns one.
                  From the docs:
                  The position descriptor word is the first 8 characters of the name of the last (most recent) label, line number, or procedure that was executed.
                  You might try the TRACE or the TRY/ END TRY error checking tools.
                  Rod
                  I want not 'not', not Knot, not Knott, not Nott, not knot, not naught, not nought, but aught.

                  Comment


                  • #10
                    Originally posted by Rodney Hicks View Post
                    However, I expect that it will return an error somewhere else in your program if it returns one.
                    There's no need for a lot of labels: Basic debugging technique, use a binary search:

                    With both DEBUG compiler instructions on, the first time you run it, it should give the name of the function/sub that the error occurs in.
                    Place a label half way through that function/sub and re-compile and re-run. This time you will either see the function or the label name.

                    If it's the function name, place a second label halfway between its current position and the function start.
                    If it's the label name place one halfway between its current position and the function end.
                    Re-compile and run again.

                    Keep halving the problem space and you quickly zero in on the problem line. Just add and delete labels as necessary - you never need more than 3 of them at any one time.

                    Comment


                    • #11
                      Originally posted by Rodney Hicks View Post
                      Ellen, I don't know anything about #DEBUG ERROR ON from using it, I've always been successful( or thought I was) using #DEBUG DISPLAY ON
                      Without DEBUG ERROR ON, array out of bound or null pointer errors are not tested. DEBUG DISPLAY ON won't tell you about those types of bugs unless you have DEBUG ERROR ON as well - you are still likely to get unidentified GPFs.


                      Comment


                      • #12
                        There's no need for a lot of labels:
                        I know that, but I figured it better for a user to figure that out on their own. (Saved me a lot of typing too!)
                        Without DEBUG ERROR ON, array out of bound or null pointer errors are not tested.
                        I don't know about the null pointers, since I rarely use pointers in my own code, but I've used DEBUG DISPLAY ON and your 'binary' approach to find many an 'out of bounds' error, it's my most common type. That being said, DEBUG ERROR ON might find my errors more quickly.
                        Rod
                        I want not 'not', not Knot, not Knott, not Nott, not knot, not naught, not nought, but aught.

                        Comment


                        • #13
                          Without DEBUG ERROR ON, array out of bound or null pointer errors are not tested.
                          But ..

                          Click image for larger version

Name:	DebugDisplayOn.PNG
Views:	326
Size:	31.5 KB
ID:	797151
                          Rgds, Dave

                          Comment


                          • #14
                            Actually I don't think it does what the OP intends.
                            That is why I asked.

                            Comment


                            • #15
                              Stuart, I am using PBCC 4.04 which apparently doesn't recognize #DEBUG DISPLAY ON. I am a free lance programmer and have been operating under the mantra of "if it ain't broke, don't fix it." This program began in 1985 written in QB for a friend--it was an easy slide into PBCC and has been humming along problem free for many years. The code in question does what it should--anytime each record is saved (in a different SUB) each of these last three memo items are trimmed and chr$(124) is added. Hence, if no memos are filled in, the record ends with three chr$(124)s, so j& is never zero.

                              It looks like I may have to face changing to a more modern language. How involved will it be to step up to PBCC 5 OR 6? Will my old Tsunami data files continue to work? Or, will I need to embark on mySQL? What about FreeBasic? Most of the programming I have done in the last few years has been MSAccess/vba. I am about to turn 80 and wish to take the path of least resistance! My first job was at Duke after graduation writing in Autocoder -- I am hoping for some sympathy and advice here!

                              Comment


                              • #16
                                You're quickest move would be to PBCC 6. There might be issues, but very few and you're learning curve is essentially joy at finding how easy it was.
                                Rod
                                I want not 'not', not Knot, not Knott, not Nott, not knot, not naught, not nought, but aught.

                                Comment


                                • #17
                                  Originally posted by Ellen Reddick View Post
                                  It looks like I may have to face changing to a more modern language. How involved will it be to step up to PBCC 5 OR 6? Will my old Tsunami data files continue to work? Or, will I need to embark on mySQL?
                                  As a database software, such as Tsunami, is running in a DLL, it is independent from the language you are calling it from. So it doesn't matter which language you are using to translate your code, as long as the calling conventions are followed.

                                  BTW, I am still using Tsunami (with PBCC 6.04 and PBWin 10.04) and its Internet-based counterpart, ttds. The latter is a neat package created by Don Dickinson. As long you are willing leave the Btrieve-oriented systems (Tsunami) you might want to have a look at a relational database, e.g. SQLite and its Internet counterpart SQLitening.

                                  And yes, I can recommend upgrading to a recent PowerBASIC version.

                                  Albert
                                  „Let the machine do the dirty work.“
                                  The Elements of Programming Style, Brian W. Kernighan, P. J. Plauger 1978

                                  Comment


                                  • #18
                                    Thank you all for your helpful comments. I am sure I will be back with more problems after I get into PBCC 6.

                                    Comment


                                    • #19
                                      I agree with previous comments. Step up to CC6. You'll be glad you did.

                                      Actually, going to PBWIN should require very little change to your actual data handling and DDT will give you a far superior user interface at the cost of a little learning.

                                      Comment


                                      • #20
                                        Stuart, I may try PBWIN after I get through PBCC 6. I have installed it and am working through debugging. Almost no problems so far ... until this: I print a lovely double line box with dividers that contain invoice data in PBCC4.
                                        Code:
                                        DATA 2 , 33 , "BROWSE DATAFILE"
                                        
                                        DATA 4 , 1 , " Co# Item Style Part Pt # Price"
                                        DATA 5 , 1 , "ÉÍÍÍÍÑÍÍÍÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍ»"
                                        DATA 6 , 1 , "º ³ ³ ³ ³ ³ º"
                                        DATA 7 , 1 , "ÈÍÍÍÍÏÍÍÍÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÏÍÍÍÍÍÍÍͼ"
                                        DATA  9 , 4  , "CFR Price? Y/N            Construction Code:            Ref.Date:"
                                        In PBCC6 the same lines print the characters as shown rather than the lines. How do I get my lines back?

                                        Comment

                                        Working...
                                        X