
Improved Quick Stats Subroutine
I have tested this a bit now and it seems to be working as intended, may still need a bit of tweaking concerning what prompt it activates on, though in most instances that would be the main prompt anyway. Consuming less than 35-lines, awesome!
Notes: Yes and No are converted to Boolean values and 'ITEM' simply refers to a capitalized value of the items within the quick-stats, if not found, TWX defaults the value to 0.
* See revision 2.02 below.
Code:
goSub :UPDATE_QSTATS
...
:UPDATE_QSTATS
# Improved Quick Stats Subroutine v1.00. Update quick stat data as a dynamic array. Use placeholder: $_QSTATS[ITEM]
setVar $break 0
setVar $stat_line ""
send "/"
waitFor "Sect"
while ($break = 0)
setVar $line CURRENTLINE
getWord $line $ck_line 1
if ($ck_line = "Command") OR ($ck_line = "Computer") OR ($ck_line = "<StarDock>")
setVar $break 1
else
mergeText $stat_line $line $stat_line
waitFor " "
end
end
# Parse and format data, e.g., data to Boolean, cleanup spaces, etc.
trim $stat_line
replaceText $stat_line #179 " "
stripText $stat_line ","
upperCase $stat_line
replaceText $stat_line "YES" 1
replaceText $stat_line "NO" 0
setVar $a 1
setVar $item ""
while ($item <> "SHIP")
getWord $stat_line $item $a
getWord $stat_line $data ($a + 1)
setVar $_QSTATS[$item] $data
add $a 2
end
return
# END UPDATE_QSTATS