_ERRORLINE abilities - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10) +---- Thread: _ERRORLINE abilities (/showthread.php?tid=2405) |
_ERRORLINE abilities - MichelleL - 01-24-2024 I'm kind of not even sure how to phrase this question. _ERRORLINE will display the line where and error is found. But say I wanted to use the command to display something different depending on where the error is found. As in bounding the error to within a section of code, as in: If _ErrorLine > 100and _ErrorLine < 150 Print "This section of code" If _ErrorLine > 200and _ErrorLine < 250 Print "This other section of code" Well, that is good, so long as I don't add more code prior to these two lines, in which case I have to keep tabs on those lines and change them each time I add or subtract prior code. Is there an ability to 'tag' something to use in place of the values? Or, maybe a different command..... RE: _ERRORLINE abilities - bplus - 01-25-2024 How about line labels? Nah, no way to connect line numbers to labels. Never liked line numbers. Could use a trip wire variable, every time the code execution passes a certain point the trip wire variable is increased by 1. Probably not good inside loops and for main code only. Report the trip wire value and you can track down where the error occured But why isn't exact line number in source code not helpful? Read the Wiki, _errorline reports the exact line number in the source code that you can see from the IDE. Also, On Error can be set for different conditions and turned off. So change that according to the message you want to make for section of code that it's covering. RE: _ERRORLINE abilities - Kernelpanic - 01-25-2024 Just show all the source code in question. There are enough excellent basic freaks here who can help you. RE: _ERRORLINE abilities - SMcNeill - 01-25-2024 Section$ = "Header" Code Code Code Code Code Code Section$ = "Middle" Code Code Code Code Code Section$ = "End" .... PRINT "Error occurred after Section:": Section$ RE: _ERRORLINE abilities - MichelleL - 01-25-2024 Here is an example: 1 On Error GoTo FAULT 2 3 '------------------------------------------------------------------------------ 4 DTE1: 'Send Date to COM5 5 A$ = Date$ 6 Put #1, , A$ 7 STATLINE$ = Date$ + " - " + Time$ + " - COM5 Date Request" 8 GoSub EVENTSAVE 9 GoSub PRINTSTAT 10 Return 11 '------------------------------------------------------------------------------ 12 TME1: 'Send Time to COM5 13 A$ = Time$ 14 Put #1, , A$ 15 STATLINE$ = Date$ + " - " + Time$ + " - COM5 Time Request" 16 GoSub EVENTSAVE 17 GoSub PRINTSTAT 18 Return 19 '------------------------------------------------------------------------------ 20 21 FAULT: 22 If _ErrorLine = 9 Print "Unable to print Date" 23 Resume 24 25 Now, if I add a bunch of code prior to Line 9, the an error occurring from that line of code will no longer print because the line number changed. That line of code is now line 11. 1 On Error GoTo FAULT 2 3 Screen 0, 1: Width 80: Color 2, 0 4 KEY Off: Cls: Close 5 '------------------------------------------------------------------------------ 6 DTE1: 'Send Date to COM5 7 A$ = Date$ 8 Put #1, , A$ 9 STATLINE$ = Date$ + " - " + Time$ + " - COM5 Date Request" 10 GoSub EVENTSAVE 11 GoSub PRINTSTAT 12 Return 13 '------------------------------------------------------------------------------ 14 TME1: 'Send Time to COM5 15 A$ = Time$ 16 Put #1, , A$ 17 STATLINE$ = Date$ + " - " + Time$ + " - COM5 Time Request" 18 GoSub EVENTSAVE 19 GoSub PRINTSTAT 20 Return 21 '------------------------------------------------------------------------------ 22 23 FAULT: 24 If _ErrorLine = 9 Print "Unable to print Date" 25 Resume I hope that makes sense...... RE: _ERRORLINE abilities - SMcNeill - 01-25-2024 Code: (Select All) 1 On Error GoTo FAULT RE: _ERRORLINE abilities - mdijkens - 01-25-2024 For these kind of things I would always use ERR: Code: (Select All) FAULT: RE: _ERRORLINE abilities - Kernelpanic - 01-25-2024 Quote:Well, that is good, so long as I don't add more code prior to these two lines, in which case I have to keep tabs on those lines and change them each time I add or subtract prior code. Is there an ability to 'tag' something to use in place of the values? Or, maybe a different command.....At GW-Basic & Co it was common practice not to write the source code in consecutive line numbers but like this: Code: (Select All)
Then one could add the necessary source code without having to change the jump addresses.
|