www.ClassicTW.com
http://www.classictw.com/

TWX Scrolling Window Example
http://www.classictw.com/viewtopic.php?f=15&t=21704
Page 1 of 1

Author:  Promethius [ Sun Mar 22, 2009 1:40 am ]
Post subject:  TWX Scrolling Window Example

The code below is an example of how to scroll data in a TWX window line by line. It does not include how to set up a window for scrolling back and forward - that requires a bit more work. The concept is similar in using arrays to contain the scroll back and a setTextOut trigger to activate the back or forward scrolling.

# Purpose:  Example of a line by line scroll in a TWX window
# Use: Start script and do a density scan, dScan output to window
# Promethius - March 2009

setVar $windowWidth 625
setVar $windowHeight 335

:createWindow
Window destWindow $windowWidth $windowHeight " Scroll Window " & GAMENAME ONTOP
setVar $lineCnt 0
setVar $destwindow ""

:dataTriggers
setTextLineTrigger sector :sector "Anom :"
setTextTrigger cmd :cmdPrompt "Command [TL="
pause

:sector
# increment line counter
add $lineCnt 1
# get line data into an array
setVar $sectInfo[$lineCnt] currentLine & "*"
# update window
gosub :destWindow
# reset our sector trigger
setTextLineTrigger sector :sector "Anom :"
pause

:cmdPrompt
# sector trigger is still active, just need to restart cmd trigger.
# For this script, we could just leave sector trigger active and not
# even use the cmd trigger, but I felt like doing it this way.
setTextTrigger cmd :cmdPrompt "Command [TL="
pause

:destWindow
setVar $rollLine1 1
setVar $rollLine2 2
# check to see if our window is full
if ($lineCnt = 20)
# set the window content var to empty
setVar $destwindow ""
While ($rollLine1 < 20)
# swap var 1 with var 2 ($sectinfo[1] will contain $sectInfo[2]
# and continue through sectinfo[19] containing sectinfo[20]
setVar $sectInfo[$rollLine1] $sectInfo[$rollLine2]
# refill out window content var with data
setVar $destwindow $destwindow & $sectInfo[$rollLine1]
add $rollLine1 1
add $rollLine2 1
end
# reset our $lineCnt to our window line max minus 1
setVar $lineCnt 19
else
# we haven't got 20 lines of data yet
setVar $destwindow $destwindow & $sectInfo[$lineCnt]
end
# display the contents in the window
setWindowContents destWindow $destWindow
return

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/