05-08-2023, 09:55 PM
(05-08-2023, 07:18 PM)SMcNeill Wrote: Wouldn't the easiest way just be to assign a global variable for debug tracing?
DIM SHARED ProgFlow$
SUB Foo
ProgFlow$ = "Foo Start"
.... sub stuff
ProgFlow$ = "Foo Clean Exit"
END SUB
Pretty much what I do. Here is a snippet of code from a massive library I'm working on:
Code: (Select All)
'+------------------+
'| Check for errors |
'+------------------+
__CURRENT_ROUTINE = "__SET_AUTO_MOTION"
IF IUO__IS_OBJECT_VALID(Handle) = 0 THEN __ERROR "The object specified does not exist."
IF FPS <> __GLOBALFPS THEN
IF FPS < 1 OR FPS > GL_FPS.FPS THEN __ERROR "FPS must be between 1 and global FPS setting of" + STR$(GL_FPS.FPS) + "."
END IF
__PREVIOUS_ROUTINE = __CURRENT_ROUTINE
I have two global shared variables, __CURRENT_ROUTINE and __PREVIOUS_ROUTINE. I set __CURRENT_ROUTINE, perform my error checks and report any errors. If no errors exist I then set __PREVIOUS_ROUTINE so I have a trail from one routine to the next. __ERROR is used to report any errors.
Code: (Select All)
SUB __ERROR (Message AS STRING) ' __ERROR |
' __________________________________________________________________________________________________________________________________________|____
'/ \
'| Set screen to text mode and display error information passed in. |
'| |
'| __ERROR "Message" |
'| |
'| NOTE: Fatal error trap - halts program execution. |
'\_______________________________________________________________________________________________________________________________________________/
_FULLSCREEN _OFF ' turn off full screen if active
SCREEN 0, 0, 0, 0 ' set screen to pure text mode
CLS ' clear screen
PLAY "l64o3ao2ao1ao3ao2ao1ao3ao2ao1a" ' get developer's attention
COLOR 12, 0
PRINT ' print error message
PRINT " Game Library has encountered the following error condition:"
COLOR 15, 0
PRINT
PRINT " Error in routine: ";
COLOR 14, 0
PRINT __CURRENT_ROUTINE
COLOR 15, 0
PRINT " Previous routine: ";
COLOR 14, 0
PRINT __PREVIOUS_ROUTINE
COLOR 11, 0
PRINT
PRINT " "; Message
COLOR 7, 0
_KEYCLEAR ' clear all key buffers
END ' terminate with "Press any key to continue..."
END SUB