User Login
Name
Password
Site Contents
News
About
Download
Scripts
Tutorials
Register
Support
FAQ
Script Reference
New User


Contact Me
Xide
Tutorials
Basic Arrays
Author: Blackice Updated: 08/27/02

Very simple example of how to use an array.
It does a density scan and grabs adjacent sectors.
---------------CODE--------------------------------
send "SD"
:Start
killTrigger getSec
setTextLineTrigger getSec :getSec "Sector"
setTextTrigger allDone :allDone "Command [TL="
pause

:getSec
add $i 1
getWord CURRENTLINE $AdjSecs[$i] 3
goto :Start

:allDone
outputvars

-------------SCREEN (edited to fit)-----------------
Long Range Scan
Select (H)olo Scan or (D)ensity Scan or (Q)uit? [D]
D Relative Density Scan
Sector 100 ==> 1,835,273 Warps : 3
Sector 6209 ==> 2,275 Warps : 4
Sector 7936 ==> 875 Warps : 3
Sector 9668 ==> 0 Warps : 4
Sector 13727 ==> 25,002,550 Warps : 6
Sector 13843 ==> 1,875 Warps : 4
Command [TL=19:56:09]:[11823] (?=Help)? :


---------------OUTPUT-----------------------------
$I = 6
$ADJSECS[1] = 100
$ADJSECS[2] = 6209
$ADJSECS[3] = 7936
$ADJSECS[4] = 9668
$ADJSECS[5] = 13727
$ADJSECS[6] = 13843

---------------ANALYSIS---------------------------
send "SD"
:Start
killTrigger getSec
setTextLineTrigger getSec :getSec "Sector"
setTextTrigger allDone :allDone "Command [TL="
pause

Sends text needed to density scan. It then restarts the Sector trigger and sets are Exit trigger

:getSec
add $i 1
getWord CURRENTLINE $AdjSecs[$i] 2
goto :Start

First time ran, $i = 0 because we haven't set $i to anything. $i is also typically used in langauges as a counter. So the first time thru, it adds 1 to $i, which would start it out to = 1. Instead of useless setVar CURRENTLINE code we can just use it in our getWord. So it grabs the 2nd word, from CURRENTLINE, and saves it into our array of $AdjSecs and stores it in slot [1], because $i = 1 right now. Next time around $i get added again, and becomes = 2. So when it stores variable into array this time, it stores in slot $i which now = 2 We add the goto :Start so it loops and is ready to grab the next sector

:allDone
outputvars

After it hits "Command [TL=" we know the sector display is over, so we can exit our script now. I just used the 'OUTPUTVARS' function so you can see all the variables used in your code and what they = at the end of the script.


----------Using data in an Array--------------------
Now that we have the array filled with out sectors, we can retrieve this data easily.

If we want to grab whats store in the 4th spot in our array(which is 9668), we reference it as $AdjSecs[4]
Same goes for spot 1 (sec 100) $AdjSecs[1]


Blackice (aka Voltron)
TWX Support Team


Return to Tutorials Page