
goSub :checkCommandPrompt~main


echo ANSI_4 "**Refresh fighter list?  "
getConsoleInput $getFigList SINGLEKEY
lowerCase $getFigList

echo ANSI_4 "****Refresh portList list?  "
getConsoleInput $getPortList SINGLEKEY
lowerCase $getPortList

if ($getFigList = "y")
  goSub :writeFigs~main
  waitFor "Command [TL="
end


if ($getPortList = "y")
  send "^?"
  waitFor "<I> Warp Display"
  waitFor ":"
  send "r"
  waitFor ":"
  send "q"
  waitFor "Command [TL="
end


goSub :readFigs

mergeText GAMENAME "-destinationList" $destinationFile 
delete $destinationFile
setVar $i 0
while ($i < SECTORS)
  add $i 1
  if (PORT.ORG[$i] > 32000)
    if (PORT.BUYFUEL[$i] = 1)
      setVar $c1 "b"
    else 
      setVar $c1 "s"
    end
    if (PORT.BUYORG[$i] = 1)
      setVar $c2 "b"
    else 
      setVar $c2 "s"
    end
    if (PORT.BUYEQUIP[$i] = 1)
      setVar $c3 "b"
    else 
      setVar $c3 "s"
    end
    if ($figgedSector[$i] <> 0)
      echo ANSI_4 $i " " $c1 $c2 $c3 " " PORT.FUEL[$i] " " PORT.PERCENTFUEL[$i] "% " PORT.ORG[$i] " " PORT.PERCENTORG[$i] "% "  PORT.EQUIP[$i] " " PORT.PERCENTEQUIP[$i] "% " PORT.UPDATED[$i] "*"
      write $destinationFile $i
    end
    if ($figgedSector[$i] = 0)
      echo ANSI_5 $i " " $c1 $c2 $c3 " " PORT.FUEL[$i] " " PORT.PERCENTFUEL[$i] "% " PORT.ORG[$i] " " PORT.PERCENTORG[$i] "% "  PORT.EQUIP[$i] " " PORT.PERCENTEQUIP[$i] "% " PORT.UPDATED[$i] " [nofig]*"
    end
  end
end

goSub :waitCommandPrompt~main
goSub :plotRoute~main

halt

:readFigs
  setVar $figFile GAMENAME & "-figreport"
  fileExists $fileExists $figFile
  if ($fileExists = 1)
    setVar $lineNumber 0
    setVar $figLine 0
    while ($figLine <> EOF)
      add $lineNumber 1
      read $figFile $figLine $lineNumber
    end
    setVar $lineCount $lineNumber
    subtract $lineCount 1
  end

  setArray $figgedSector SECTORS
  setVar $i 1
  while ($i <= SECTORS)
    setVar $figgedSector[$i] 0
    add $i 1
  end

  setVar $lineNumber 0
  setVar $figLine " "
  while ($figLine <> EOF)
    add $lineNumber 1
    read $figFile $figLine $lineNumber
    if ($figLine <> EOF)
      getWord $figLine $sector 1
      getWord $figLine $figCount 2
      setVar $figgedSector[$sector] $figcount
      #echo $sector " " $figgedSector[$sector] " *"
    end
  end

  ## Debug
  #setVar $i 1
  #while ($i <= SECTORS)
  #  echo $figgedSector[$i] " "
  #  add $i 1
  #end


return


halt
include "lib\plotRoute.ts"
include "lib\waitCommandPrompt.ts"
include "lib\checkCommandPrompt.ts"
include "lib\writeFigs.ts"
