CODE
Code : Tout sélectionner
;----------------------------------------------------------------------------------------
;----MACRO sDebug pour afficher sur une seule ligne NOM DE VARIABLE ET VALEUR
; (Pour les constantes utiliser sDebug SANS #
; UTILISATION: sDebug (variable [, "commentaire"])
Macro Guillemet
"
EndMacro
Macro sDebug (sDpar1, sDpar2="")
CompilerIf #PB_Compiler_Debugger ;SI debogueur actif
CompilerIf Defined(sDpar1, #PB_Constant) ;UNE CONSTANTE? (ici sans dièse)
Debug "#"+Guillemet#sDpar1#Guillemet + ": " + #sDpar1 +" "+sDpar2
CompilerElse ;UNE VARIABLE (Les Str(...) ne semblent plus utiles...(?)
CompilerSelect TypeOf(sDpar1)
; ----ENTIERS SIGNÉS
CompilerCase #PB_Byte
Debug Guillemet#sDpar1#Guillemet + ".b: " +Str(sDpar1) +" "+sDpar2
CompilerCase #PB_Word
Debug Guillemet#sDpar1#Guillemet + ".w: " +Str(sDpar1) +" "+sDpar2
CompilerCase #PB_Long
Debug Guillemet#sDpar1#Guillemet + ".l: " +Str(sDpar1) +" "+sDpar2
CompilerCase #PB_Integer
Debug Guillemet#sDpar1#Guillemet + ".i: " +Str(sDpar1) +" "+sDpar2
; ----ENTIERS NON SIGNÉS
CompilerCase #PB_Ascii
Debug Guillemet#sDpar1#Guillemet + ".a: " +StrU(sDpar1) +" "+sDpar2
CompilerCase #PB_Character
Debug Guillemet#sDpar1#Guillemet + ".c: " +StrU(sDpar1) +" "+sDpar2
CompilerCase #PB_Unicode
Debug Guillemet#sDpar1#Guillemet + ".u: " +StrU(sDpar1) +" "+sDpar2
; ----FLOTTANT / DOUBLE
CompilerCase #PB_Float
Debug Guillemet#sDpar1#Guillemet + ".f: " +StrF(sDpar1) +" "+sDpar2
CompilerCase #PB_Double
Debug Guillemet#sDpar1#Guillemet + ".d: " +StrD(sDpar1) +" "+sDpar2
; ----STRING
CompilerCase #PB_String
Debug Guillemet#sDpar1#Guillemet + ".s: " + sDpar1 +" "+sDpar2
; ----AUTRE?
CompilerDefault
CompilerError "Type Inconnu"
CompilerEndSelect
CompilerEndIf;VARIABLE
CompilerEndIf ;debogueur actif
EndMacro ;sDebug
;----------------------------------------------------------------------------------------
;exemples
MaVariable= 10
UneAutre$= "bla bla"
machin.f= 2/3
sDebug(MaVariable) ; MaVariable.i: 10
sDebug(UneAutre$, " j'dis ça j'dis rien") ;UneAutre$.s: bla bla j'dis ça j'dis rien
sDebug(machin) ;machin.f: 0.6666666865
;----------------------------------------------------------------------------------------
( Edit modo: Ajout balise [ code-pb ] ... [ / code-pb ] )