[REBOL] debugging rebol apps Re:
From: jelinem1:nationwide at: 18-Sep-2000 8:59
Well, since you asked...
I have a fairly large application, divided into several files (modules). My
traditional approach to debugging when I have no "debugger" is to write a
function which prints its argument only when a global variable is set. This
allows me to print messages about the program's behavior while testing,
then turn off those messages when the program works. For a large app I have
developed this to the following:
In the first file which gets loaded into the REBOL session I define the
following flags:
testing: make object! [
all: false
adv: false
item: false
event: true
lib: false
main: false
melee: true
menu: false
mon: false
party: true
play: true
player: true
room: false
util: false
weap: false
]
Where each element represents a module of the program. Then the
testing-print function is defined as follows:
eprint: make object! [
adv: func [msg-raw [series!]][ if any [testing/adv testing/all][print
[ "^(tab)ADV: " reduce msg-raw ]]]
dun: func [msg-raw [series!]][ if any [testing/lib testing/all][print
[ "^(tab)DUNGEON: " reduce msg-raw ]]]
event: func [msg-raw [series!]][ if any [testing/event
testing/all][print [ "^(tab)EVENT: " reduce msg-raw ]]]
item: func [msg-raw [series!]][ if any [testing/weap
testing/all][print [ "^(tab)WEAP: " reduce msg-raw ]]]
lib: func [msg-raw [series!]][ if any [testing/lib testing/all][print
[ "^(tab)LIBRARY: " reduce msg-raw ]]]
main: func [msg-raw [series!]][ if any [testing/main
testing/all][print [ "^(tab)MAIN: " reduce msg-raw ]]]
melee: func [msg-raw [series!]][ if any [testing/melee
testing/all][print [ "^(tab)MELEE: " reduce msg-raw ]]]
menu: func [msg-raw [series!]][ if any [testing/menu
testing/all][print [ "^(tab)MENU: " reduce msg-raw ]]]
mon: func [msg-raw [series!]][ if any [testing/mon testing/all][print
[ "^(tab)MON: " reduce msg-raw ]]]
party: func [msg-raw [series!]][ if any [testing/party
testing/all][print [ "^(tab)PARTY: " reduce msg-raw ]]]
play: func [msg-raw [series!]][ if any [play-test testing/all][print
[ "^(tab)PLAY: " reduce msg-raw ]]]
player: func [msg-raw [series!]][ if any [testing/play
testing/all][print [ "^(tab)PLAYER: " reduce msg-raw ]]]
room: func [msg-raw [series!]][ if any [testing/room
testing/all][print [ "^(tab)ROOM: " reduce msg-raw ]]]
util: func [msg-raw [series!]][ if any [testing/util
testing/all][print [ "^(tab)UTIL: " reduce msg-raw ]]]
weap: func [msg-raw [series!]][ if any [testing/weap
testing/all][print [ "^(tab)WEAP: " reduce msg-raw ]]]
report: func ["Report the testing status"][
if play-test [print "* Game is being PLAY-TESTED."]
if testing/all [print "* Everything is being error-tested."]
foreach test-var (next first testing) [
if true = get in testing test-var [print ["*" test-var "is
being error-tested."]]
]
]
]
I can turn on ALL testing messages simply by setting:
testing/all: true
Or any individual module testing messages by, for example:
testing/main: true
I can then define a testing message by the following (for some reason I
don't need 'reform on the parameter block before passing it):
eprint/adv [ "Creating char:" form class-fields ", weapon:" wname ",
armor:" aname ", shield:" sname]
eprint/melee [ "Defender:" combatant/target/name " hp:" combatant/target/hp
]
eprint/report ; Displays all module being tested
- Michael Jelinek
[rishi--picostar--com] on 09/16/2000 08:57:16 PM
From: [rishi--picostar--com] on 09/16/2000 08:57 PM
Please respond to [list--rebol--com]
To: [list--rebol--com]
cc:
Subject: [REBOL] debugging rebol apps
Hi. Since rebol does not have a compiler, I find it a bit more difficult to
debug large rebApps.
Anyone have any debugging tips/strategies? Curious how others debug their
scripts...
Rishi