Allowing "Comment Recorded" in Hugo
Posted: Mon Nov 05, 2007 9:12 am
Bert Byfield posted a slick Hugo mod to the newsgroup, for allowing the parser to recognize "*" as a comment line (instead of defaulting to an unrecognized message from the parser).
I took that and worked it into some code that should be pretty easy to plug into any Hugo program. If you're already doing a REPLACE on NewParseError or NewVMessage, you'd want to just include that code in your existing ones. If not, just copy as-is.
Kent -- any chance of getting this into the base Hugo Lib? That'd be cool... :)
It may need some testing. It *seems* to work okay for me, but I haven't done tremendous testing on it yet. Here it is, though.
First, you need to add a "global" variable to the program (somewhere near the top, after your #includes:
And then, just put all of this somewhere in your program. Voila! Now commands that start with an asterisk are recognized as comment lines!
I took that and worked it into some code that should be pretty easy to plug into any Hugo program. If you're already doing a REPLACE on NewParseError or NewVMessage, you'd want to just include that code in your existing ones. If not, just copy as-is.
Kent -- any chance of getting this into the base Hugo Lib? That'd be cool... :)
It may need some testing. It *seems* to work okay for me, but I haven't done tremendous testing on it yet. Here it is, though.
First, you need to add a "global" variable to the program (somewhere near the top, after your #includes:
Code: Select all
global transcript_is_on = false
Code: Select all
replace DoScriptOnOff
{
if word[2] = "on" or words = 1
{
if (transcript_is_on) or (not scripton)
VMessage(&DoScriptOnOff, 1) ! "Unable to begin..."
else
{
transcript_is_on = true
VMessage(&DoScriptOnOff, 2) ! "Transcription on."
}
}
elseif word[2] = "off"
{
if (not transcript_is_on) or (not scriptoff)
VMessage(&DoScriptOnOff, 3) ! "Unable to end..."
else
{
transcript_is_on = false
VMessage(&DoScriptOnOff, 4) ! "Transcription off."
}
}
}
replace NewParseError(errornumber, obj)
{
string(_temp_string, parse$, 1) !get 1st byte of input
if (_temp_string[0] = '*')
{
if (transcript_is_on)
VMessage(&DoScriptOnOff, 5) ! Comment recorded!
else
VMessage(&DoScriptOnOff, 6) ! Comment not recorded!
return true
}
}
replace NewVMessages(r, num, a, b)
{
select r
case &DoScriptOnOff
{
select num
case 1
{
if (transcript_is_on)
print "Transcription is already on."
else
print "Unable to begin transcription."
}
case 2: print "Transcription on."
case 3
{
if (not transcript_is_on)
print "Transcription is not currently on."
else
print "Unable to end transcription."
}
case 4: print "Transcription off."
case 5: print "Comment recorded!"
case 6: print "Comment not recorded!"
return true
}
return false !So all other VMessages work as-is.
}