home *** CD-ROM | disk | FTP | other *** search
/ Star Trek Starfleet Academy Mini Omnipedia / MINI_OMNI.ISO / pc / omni_v2.dxr / 00380_utilities.ls < prev    next >
Encoding:
Text File  |  1996-04-15  |  8.0 KB  |  276 lines

  1. global gNopeSND
  2.  
  3. on hVerifyCastTable
  4.   put "Lefferts algorithms compiling..." into field "Status"
  5.   set Ltemplist to [:]
  6.   set Ltemplist to value(the text of cast "CastTable500")
  7.   set Lmax to count(Ltemplist)
  8.   repeat with i = 1 to Lmax
  9.     set Lcstnum to getPropAt(Ltemplist, i)
  10.     set Lcstname to getAt(Ltemplist, i)
  11.     if the name of cast Lcstnum <> Lcstname then
  12.       beep(2)
  13.       return 
  14.     end if
  15.   end repeat
  16.   put "Lefferts algorithms compiling (level 2 of 3)..." into field "Status"
  17.   set Ltemplist to [:]
  18.   set Ltemplist to value(the text of cast "CastTable1000")
  19.   set Lmax to count(Ltemplist)
  20.   repeat with i = 1 to Lmax
  21.     set Lcstnum to getPropAt(Ltemplist, i)
  22.     set Lcstname to getAt(Ltemplist, i)
  23.     if the name of cast Lcstnum <> Lcstname then
  24.       beep(2)
  25.       return 
  26.     end if
  27.   end repeat
  28.   put "Lefferts algorithms compiling (level 3 of 3)..." into field "Status"
  29.   set Ltemplist to [:]
  30.   set Ltemplist to value(the text of cast "CastTable2000")
  31.   set Lmax to count(Ltemplist)
  32.   repeat with i = 1 to Lmax
  33.     set Lcstnum to getPropAt(Ltemplist, i)
  34.     set Lcstname to getAt(Ltemplist, i)
  35.     if the name of cast Lcstnum <> Lcstname then
  36.       beep(2)
  37.       return 
  38.     end if
  39.   end repeat
  40.   put "Lefferts algorithms verified!" into field "Status"
  41. end
  42.  
  43. on hMouseEventReport
  44.   return RETURN & "CLICK! on cast" && the name of cast the castNum of sprite the clickOn
  45. end
  46.  
  47. on hGenGlobCntLst pWhatMode
  48.   if pWhatMode = #CHRO then
  49.     set Lpntrlist to [18, 19, 20, 21, 22, 23, 24]
  50.   end if
  51.   set Lgc to 1
  52.   repeat with i in Lpntrlist
  53.     set Lfldname to "ATTRIB_" & string(i) & "_" & pWhatMode
  54.     put "In field " & Lfldname
  55.     set Lthisgroup to value(field Lfldname)
  56.     set Lthissize to count(Lthisgroup)
  57.     repeat with x = 1 to Lthissize
  58.       put Lgc & ":" & getPropAt(Lthisgroup, x)
  59.       set Lgc to Lgc + 1
  60.     end repeat
  61.   end repeat
  62. end
  63.  
  64. on stall
  65.   put "--STALL ACTIVE: hit shift to proceed--+ command to abort"
  66.   repeat while not (the shiftDown)
  67.     nothing()
  68.   end repeat
  69.   if the commandDown then
  70.     beep(2)
  71.     abort()
  72.   end if
  73. end
  74.  
  75. on tellerror fileName, Ltheproblem
  76.   if Ltheproblem = -43 then
  77.     set errmsg to " File" && fileName && "not found"
  78.     put errmsg
  79.     exit
  80.   end if
  81.   if Ltheproblem = -33 then
  82.     set errmsg to " File directory full"
  83.   end if
  84.   if Ltheproblem = -34 then
  85.     set errmsg to " Volume full"
  86.   end if
  87.   if Ltheproblem = -35 then
  88.     set errmsg to " Volume not found"
  89.   end if
  90.   if Ltheproblem = -36 then
  91.     set errmsg to " I/O Error"
  92.   end if
  93.   if Ltheproblem = -37 then
  94.     set errmsg to " Bad file name"
  95.   end if
  96.   if Ltheproblem = -38 then
  97.     set errmsg to " File not open"
  98.   end if
  99.   if Ltheproblem = -42 then
  100.     set errmsg to " Too many files open"
  101.   end if
  102.   if Ltheproblem = -56 then
  103.     set errmsg to " No such drive"
  104.   end if
  105.   if Ltheproblem = -65 then
  106.     set errmsg to " No disk in drive"
  107.   end if
  108.   if Ltheproblem = -120 then
  109.     set errmsg to " Directory not found for" && fileName
  110.     put errmsg && "at frame #" & the frame
  111.     exit
  112.   end if
  113.   hReportStatus("Text file read/write not sucessful." & RETURN & "Code: " & errmsg && Ltheproblem)
  114.   hearit(gNopeSND)
  115. end
  116.  
  117. on hputmsg what
  118.   put what
  119. end
  120.  
  121. on confirmpathset castNum, yePath
  122.   preLoadCast(castNum)
  123.   if the result <> castNum then
  124.     hReportStatus("Cast" && castNum && "not successfully preloaded.")
  125.     hearit(gNopeSND)
  126.   end if
  127.   if the fileName of cast castNum <> yePath then
  128.     hReportStatus("The file you wanted to load into cast" && castNum && "could not be found at path" && yePath)
  129.     hearit(gNopeSND)
  130.   end if
  131. end
  132.  
  133. on hExportEntries begin, end
  134.   global gWriteObject
  135.   repeat with x = begin to end
  136.     set gWriteObject to FileIO(mnew, "write", the pathName & "OldAttribs-" & x)
  137.     set vMyList to [:]
  138.     sort(vMyList)
  139.     set vMyList to value(the text of cast x)
  140.     set y to count(vMyList)
  141.     set vTextHolder to EMPTY
  142.     repeat with i = 1 to y
  143.       put getPropAt(vMyList, i) after vTextHolder
  144.       put RETURN after vTextHolder
  145.     end repeat
  146.     set thetext to vTextHolder
  147.     gWriteObject(mWriteString, thetext)
  148.     gWriteObject(mdispose)
  149.     put x & " is Done"
  150.   end repeat
  151. end
  152.  
  153. on hSortAttrib begin, end
  154.   repeat with i = begin to end
  155.     set vTempText to [:]
  156.     sort(vTempText)
  157.     set vTempText to value(the text of cast i)
  158.     sort(vTempText)
  159.     set the text of cast i to string(vTempText)
  160.     put "cast " && i && "done. next..."
  161.   end repeat
  162. end
  163.  
  164. on hAttribHunter pSourceCast, pLookeeheah
  165.   global gFirstChar, vSourceList, vInfoList
  166.   set gFirstChar to "A"
  167.   set vSourceList to [:]
  168.   set vSourceList to value(the text of cast pSourceCast)
  169.   set vInfoList to [:]
  170.   set vInfoList to value(the text of cast pLookeeheah)
  171.   set vMax to count(vSourceList)
  172.   repeat with i = 1 to vMax
  173.     put gFirstChar
  174.     if char 1 of string(getPropAt(vSourceList, i)) <> gFirstChar then
  175.       set gFirstChar to char 1 of string(getPropAt(vSourceList, i))
  176.       set vInfoList to value(the text of cast ("ATTRIB_" & gFirstChar & "_ENCY"))
  177.     end if
  178.     set x to getPropAt(vSourceList, i)
  179.     set vtempList to []
  180.     set vtempList to getProp(vInfoList, x)
  181.     set vTempListTwo to []
  182.     repeat with m = 9 to 10
  183.       append(vTempListTwo, getAt(vtempList, m))
  184.     end repeat
  185.     setAt(vSourceList, i, vTempListTwo)
  186.   end repeat
  187.   set the text of field pSourceCast to string(vSourceList)
  188. end
  189.  
  190. on hFixThis pThisCast
  191.   set vFromThis to the text of cast pThisCast
  192.   set vFromThis to value(vFromThis)
  193.   set vholdletter to 0
  194.   repeat with x = 1 to count(vFromThis)
  195.     set vNewValue to getAt(vFromThis, x)
  196.     set vtheNinth to getAt(vNewValue, 9)
  197.     set vtheTenth to getAt(vNewValue, 10)
  198.     set vtheProperty to getPropAt(vFromThis, x)
  199.     set vtheLetter to char 1 of vtheProperty
  200.     if vtheLetter <> vholdletter then
  201.       set vExistingAttrib to the text of cast ("ATTRIB_" & vtheLetter & "_ENCY")
  202.     end if
  203.     set vExistingAttrib to value(vExistingAttrib)
  204.     set vOldValue to getProp(vExistingAttrib, vtheProperty)
  205.     set vthePosition to getPos(vExistingAttrib, vOldValue)
  206.     setAt(vOldValue, 9, vtheNinth)
  207.     setAt(vOldValue, 10, vtheTenth)
  208.     set vNewValue to vOldValue
  209.     setAt(vExistingAttrib, vthePosition, vNewValue)
  210.     set the text of cast ("ATTRIB_" & vtheLetter & "_ENCY") to string(vExistingAttrib)
  211.     set vholdletter to vtheLetter
  212.   end repeat
  213. end
  214.  
  215. on hNukeOldText prevlist
  216.   set the itemDelimiter to "~"
  217.   set vtheProp to 0
  218.   set vtheNukeCast to 0
  219.   set vtheNukeItem to 0
  220.   set vEditHere to 0
  221.   set vEntriesToGo to prevlist
  222.   set vGuideList to the text of cast vEntriesToGo
  223.   set vGuideList to value(vGuideList)
  224.   repeat with i = 1 to count(vGuideList)
  225.     set vtheProp to getAt(vGuideList, i)
  226.     set vtheNukeCast to getAt(vtheProp, 1)
  227.     set vtheNukeItem to getAt(vtheProp, 2)
  228.     set vEditHere to the text of cast vtheNukeCast
  229.     put "~" & RETURN & RETURN after item vtheNukeItem of vEditHere
  230.     delete item vtheNukeItem of vEditHere
  231.     set the text of cast vtheNukeCast to vEditHere
  232.   end repeat
  233.   set the itemDelimiter to ","
  234. end
  235.  
  236. on hExtractEntries pFromTextCast
  237.   set vTempCast to the text of cast pFromTextCast
  238.   set vEntriesList to []
  239.   set itemDelimiter to "~"
  240.   set n to 1
  241.   repeat with i = 2 to the number of items in vTempCast
  242.     set n to string(count(vEntriesList) + 1)
  243.     set vItemHolder to item i of vTempCast
  244.     set the itemDelimiter to "@"
  245.     delete char 1 of vItemHolder
  246.     add(vEntriesList, RETURN & pFromTextCast & ":" & n && vItemHolder)
  247.     set itemDelimiter to "~"
  248.     set i to i + 1
  249.   end repeat
  250.   put vEntriesList
  251. end
  252.  
  253. on hScanForXChar aFieldNum, b
  254.   repeat with mm = aFieldNum to b
  255.     set vSize to the number of chars in field mm
  256.     put "Scanning" && vSize & " chars in field " & the name of cast mm
  257.     put "Hit SHIFT to abort"
  258.     set i to 1
  259.     repeat while not (the shiftDown)
  260.       if i > vSize then
  261.         exit repeat
  262.       end if
  263.       set vCode to charToNum(char i of field mm)
  264.       if vCode < 32 then
  265.         put "CHAR" && i && "is >" & char i of field mm & "< ascii:" & vCode
  266.       else
  267.         if vCode > 127 then
  268.           put "CHAR" && i && "is >" & char i of field mm & "< ascii:" & vCode
  269.         end if
  270.       end if
  271.       set i to i + 1
  272.     end repeat
  273.   end repeat
  274.   put "THAT'S IT"
  275. end
  276.