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

  1. property iFileDelimiter, iToolsPath, iLauncherPath, iAssetsPath, iIntroPath, iUserDictPath, iMainMenuPath, iLastTextFileRead, iCFTPath, iCTwoPath, iDumpData
  2.  
  3. on birth me
  4.   global iam, mpciopath, gDevelopmentmode, gRunFromCD, gPrintObjectPath
  5.   set mpciopath to the pathName & "fileio.dll"
  6.   mDetectSys(me)
  7.   if iam = #mpc then
  8.     set iFileDelimiter to "\"
  9.   else
  10.     set iFileDelimiter to ":"
  11.   end if
  12.   set iLastTextFileRead to EMPTY
  13.   set iDumpData to EMPTY
  14.   return me
  15. end
  16.  
  17. on mGetFileDelimiter me
  18.   return iFileDelimiter
  19. end
  20.  
  21. on mFileIsHere me, pFileWithPath
  22.   global theProblem, iam, mpciopath
  23.   if iam = #mpc then
  24.     openXLib(mpciopath)
  25.   end if
  26.   set vTempObj to FileIO(mnew, "read", pFileWithPath)
  27.   if objectp(vTempObj) then
  28.     vTempObj(mdispose)
  29.     if iam = #mpc then
  30.       closeXLib(mpciopath)
  31.     end if
  32.     return 1
  33.   else
  34.     if iam = #mpc then
  35.       closeXLib(mpciopath)
  36.     end if
  37.     return 0
  38.   end if
  39. end
  40.  
  41. on mDetectSys me
  42.   global iam
  43.   if the machineType < 256 then
  44.     set iam to #mac
  45.   else
  46.     set iam to #mpc
  47.   end if
  48.   if (iam = #mac) and not (the quickTimePresent) then
  49.     alert("Sorry, this product requires the presence of the Quicktime‚Ñ¢ system extension in your extensions folder.")
  50.     quit()
  51.   end if
  52. end
  53.  
  54. on mGetLastTextFile me
  55.   return iLastTextFileRead
  56. end
  57.  
  58. on mGetFile me, pFileWithPath
  59.   global iam, mpciopath
  60.   if iam = #mpc then
  61.     openXLib(mpciopath)
  62.   end if
  63.   set vTempFile to FileIO(mnew, "READ", pFileWithPath)
  64.   set vNewText to EMPTY
  65.   if objectp(vTempFile) then
  66.     set vNewText to vTempFile(mReadFile)
  67.     set iLastTextFileRead to vTempFile(mFileName)
  68.     vTempFile(mdispose)
  69.   end if
  70.   if iam = #mpc then
  71.     closeXLib(mpciopath)
  72.   end if
  73.   return vNewText
  74. end
  75.  
  76. on mGetAnyFile me
  77.   global iam, mpciopath
  78.   if iam = #mpc then
  79.     openXLib(mpciopath)
  80.   end if
  81.   set vTempFile to FileIO(mnew, "?READ", "TXT")
  82.   set vNewText to EMPTY
  83.   if objectp(vTempFile) then
  84.     set vNewText to vTempFile(mReadFile)
  85.     set iLastTextFileRead to vTempFile(mFileName)
  86.     vTempFile(mdispose)
  87.   end if
  88.   if iam = #mpc then
  89.     closeXLib(mpciopath)
  90.   end if
  91.   return vNewText
  92. end
  93.  
  94. on mSaveFile me, pTextString, pfilename
  95.   global iam, mpciopath
  96.   if iam = #mpc then
  97.     openXLib(mpciopath)
  98.   end if
  99.   set vTempFile to FileIO(mnew, "read", pfilename)
  100.   if objectp(vTempFile) then
  101.     vTempFile(mDelete)
  102.   end if
  103.   set vTempFile to FileIO(mnew, "write", pfilename)
  104.   if objectp(vTempFile) then
  105.     vTempFile(mWriteString, pTextString)
  106.     set iLastTextFileRead to vTempFile(mFileName)
  107.     vTempFile(mdispose)
  108.   end if
  109.   if iam = #mpc then
  110.     closeXLib(mpciopath)
  111.   end if
  112. end
  113.  
  114. on mSaveAsFile me, pTextString, pSuggestedname
  115.   global iam, mpciopath
  116.   if iam = #mpc then
  117.     openXLib(mpciopath)
  118.   end if
  119.   if voidp(pSuggestedname) or (pSuggestedname = EMPTY) then
  120.     set pSuggestedname to "Untitled"
  121.   end if
  122.   set vTempFile to FileIO(mnew, "?write", pSuggestedname)
  123.   if objectp(vTempFile) then
  124.     vTempFile(mWriteString, pTextString)
  125.     set iLastTextFileRead to vTempFile(mFileName)
  126.     vTempFile(mdispose)
  127.   end if
  128.   if iam = #mpc then
  129.     closeXLib(mpciopath)
  130.   end if
  131. end
  132.  
  133. on mGetFolderFiles me, pFolderwithpath
  134.   set vFound to 1
  135.   set vList to []
  136.   set vIndex to 1
  137.   repeat while vFound
  138.     set vFileName to getNthFileNameInFolder(pFolderwithpath, vIndex)
  139.     set vFound to vFileName <> EMPTY
  140.     add(vList, vFileName)
  141.     set vIndex to vIndex + 1
  142.   end repeat
  143.   set vIndex to vIndex - 1
  144.   deleteAt(vList, vIndex)
  145.   return vList
  146. end
  147.