home *** CD-ROM | disk | FTP | other *** search
/ T-Shirt Design Shop / TSHIRT_Designer.ISO / data / odata1 / mcards / notes.dxr / 00162_fileParam.ls < prev    next >
Encoding:
Text File  |  1998-05-02  |  2.6 KB  |  115 lines

  1. on loadParams
  2.   set params to readParams()
  3.   set the exitLock to 1
  4.   when keyDown then checkKeyDown()
  5.   set params to initBasicParams(params)
  6.   put item 1 of params into field "soundFileName"
  7.   if offset("noName", field "soundFileName") = 1 then
  8.     put "noName" into field "soundFileName"
  9.   end if
  10.   if the machineType < 256 then
  11.     exportSoundToFile()
  12.   end if
  13.   setColorDepth(1)
  14.   set tmp to field "to" & RETURN & field "Mess" & RETURN & field "from"
  15.   if the number of lines in tmp <= 3 then
  16.     put RETURN & tmp into field "allmess"
  17.   else
  18.     put tmp into field "allmess"
  19.   end if
  20. end
  21.  
  22. on setColorDepth sw_start
  23.   global prevColorDepth
  24.   if sw_start then
  25.     if the colorDepth <> 8 then
  26.       set prevColorDepth to the colorDepth
  27.       set the colorDepth to 8
  28.     else
  29.       set prevColorDepth to 0
  30.     end if
  31.   else
  32.     deleteFile(the pathName & field "soundFileName")
  33.     if prevColorDepth <> 0 then
  34.       set the colorDepth to prevColorDepth
  35.     end if
  36.   end if
  37. end
  38.  
  39. on deleteFile theFileName
  40.   if the machineType < 256 then
  41.     set f to FileIO(mnew, "read", theFileName)
  42.     if objectp(f) then
  43.       f(mDelete)
  44.     end if
  45.   end if
  46. end
  47.  
  48. on checkKeyDown
  49.   dontPassEvent()
  50.   if the keyCode = 53 then
  51.     set swOut to 1
  52.   else
  53.     set swOut to 0
  54.   end if
  55.   if the commandDown then
  56.     if (the key = "Q") or (the key = "q") or (the key = ".") then
  57.       set swOut to 1
  58.     end if
  59.   end if
  60.   if swOut then
  61.     when keyDown then nothing
  62.     repeat with sprt = 1 to 48
  63.       puppetSprite(sprt, 0)
  64.     end repeat
  65.     go("cprts1")
  66.   end if
  67. end
  68.  
  69. on exportSoundToFile
  70.   if field "soundFileName" <> "noName" then
  71.     set err to copyResToSnd(the pathName & field "soundFileName", field "soundFileName")
  72.     if err <> "0" then
  73.       alert(err)
  74.     end if
  75.   end if
  76. end
  77.  
  78. on readParams
  79.   global file
  80.   if the machineType >= 256 then
  81.     set fileName to the pathName & field "fName"
  82.     set ret to EMPTY
  83.     set file to FileIO(mnew, "read", fileName)
  84.     if not objectp(file) then
  85.       fileError(file)
  86.       halt()
  87.     end if
  88.     set ret to file(mReadFile)
  89.     file(mdispose)
  90.   else
  91.     set ret to getStrRes("AGprefs")
  92.   end if
  93.   set charsNum to integer(line 1 of ret)
  94.   delete line 1 of ret
  95.   if the number of chars in ret <> charsNum then
  96.     alert("Inappropriate preferences file. Program aborting.")
  97.     halt()
  98.   end if
  99.   return ret
  100. end
  101.  
  102. on fileError file
  103.   set err to string(file)
  104.   alert("Problem accessing file, error=" && err)
  105. end
  106.  
  107. on initBasicParams params
  108.   put line 1 of params into field "From"
  109.   put line 2 of params into field "To"
  110.   set len to integer(line 3 of params)
  111.   put line 4 to 3 + len of params into field "Mess"
  112.   delete line 1 to 3 + len of params
  113.   return params
  114. end
  115.