Code: Select all
CompilerIf #PB_Compiler_Debugger
Import "Debugger.lib"
PB_DEBUGGER_SendError(error.s)
EndImport
Macro sgxERROR(_message_)
PB_DEBUGGER_SendError("sgx ERROR: "+_message_)
EndMacro
; [...]
Code: Select all
CompilerIf #PB_Compiler_Debugger
Import "Debugger.lib"
PB_DEBUGGER_SendError(error.s)
EndImport
Macro sgxERROR(_message_)
PB_DEBUGGER_SendError("sgx ERROR: "+_message_)
EndMacro
; [...]
Code: Select all
ProcedureDLL MyDiv(a, b)
ProcedureReturn a/b
EndProcedure
ProcedureCDLL MyDiv_DEBUG(a, b)
If b=0
TB_DebugError("Division by zero!")
EndIf
EndProcedure
Code: Select all
;{ ---------------- MACRO: sgx()
CompilerIf #PB_Compiler_Debugger
Import "Debugger.lib"
PB_DEBUGGER_SendError(error.s)
EndImport
Macro sgxERROR(_message_)
PB_DEBUGGER_SendError("sgx ERROR: "+_message_)
EndMacro
Macro sgx_debugger_check_array_bounds(index)
index * bool( ((index>=0) And (index<=sgx_CURRENT_MAX_DYNAMIC_GADGETS)) Or sgxERROR("array out of bounds: sgx("+Str(index)+")") )
EndMacro
; ****************************
Macro sgx(index)
*sgxID(sgx_debugger_check_array_bounds(index))
EndMacro
; ****************************
; ----------------
CompilerElse
Macro sgxERROR(_message_)
; <empty>
EndMacro
; ****************************
Macro sgx(index)
*sgxID(index)
EndMacro
; ****************************
CompilerEndIf ;}
; ----------------
Code: Select all
; the actual array is: Dim *sgxID.<structure>(..)
; boundary check if debugger enabled
sgx(id)\text = "bla"