ERRORLINE: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
(Created page with "{{DISPLAYTITLE:_ERRORLINE}} The _ERRORLINE function returns the source code line number that caused the most recent runtime error. {{PageSyntax}} :{{Parameter|e%}} = _ERRORLINE {{PageDescription}} * Used in program error troubleshooting. * Does not require that the program use line numbers as it counts the actual lines of code. * The code line can be found using the QB64 IDE (Use the shortcut '''Ctrl+G''' to go to a specific line) or any other text editor suc...")
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 15: Line 15:
{{PageExamples}}
{{PageExamples}}
''Example:'' Displaying the current program line using a simulated [[ERROR]] code.
''Example:'' Displaying the current program line using a simulated [[ERROR]] code.
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|ON ERROR}} {{Cl|GOTO}} DebugLine 'can't use {{Cl|GOSUB}}  
{{Cl|ON ERROR}} {{Cl|GOTO}} DebugLine {{Text|<nowiki>'can't use GOSUB</nowiki>|#919191}}


{{Cl|ERROR}} 250 'simulated error code  
{{Cl|ERROR}} {{Text|250|#F580B1}} {{Text|<nowiki>'simulated error code</nowiki>|#919191}}


{{Cl|END}}  
{{Cl|END}}
DebugLine:  
DebugLine:
{{Cl|PRINT}} {{Cl|_ERRORLINE}}  
{{Cl|PRINT}} {{Cl|_ERRORLINE}}
{{Cl|RESUME}} {{Cl|NEXT}} '' ''
{{Cl|RESUME}} {{Cl|NEXT}}
{{CodeEnd}}
{{CodeEnd}}



Latest revision as of 21:18, 28 March 2023

The _ERRORLINE function returns the source code line number that caused the most recent runtime error.


Syntax

e% = _ERRORLINE


Description

  • Used in program error troubleshooting.
  • Does not require that the program use line numbers as it counts the actual lines of code.
  • The code line can be found using the QB64 IDE (Use the shortcut Ctrl+G to go to a specific line) or any other text editor such as Notepad.


Examples

Example: Displaying the current program line using a simulated ERROR code.

ON ERROR GOTO DebugLine 'can't use GOSUB

ERROR 250 'simulated error code

END
DebugLine:
PRINT _ERRORLINE
RESUME NEXT


See also



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link