home *** CD-ROM | disk | FTP | other *** search
/ Passport / passport.iso / pc / passport / notepad.dxr / Internal_1.ls < prev    next >
Encoding:
Text File  |  1998-01-26  |  5.1 KB  |  232 lines

  1. global HDDir
  2.  
  3. on startMovie
  4. end
  5.  
  6. on closeWindow
  7.   set the visible of sprite 12 to 0
  8.   set the visible of sprite 14 to 0
  9.   if the frame > 2 then
  10.     save()
  11.   end if
  12. end
  13.  
  14. on idle
  15.   set CursorList to [3, 4, 6, 7, 8, 9, 10, 13, 15]
  16.   repeat with i in CursorList
  17.     if rollOver(i) then
  18.       if (i < 15) or ((the frame = 2) and (the mouseLine > 0)) then
  19.         cursor([50, 51])
  20.         exit
  21.       end if
  22.     end if
  23.   end repeat
  24.   cursor(-1)
  25. end
  26.  
  27. on Drag str
  28.   cursor([10, 11])
  29.   repeat while the stillDown
  30.     nothing()
  31.   end repeat
  32.   cursor(-1)
  33.   set M to the mouseCast
  34.   if (M > 18) and (M < 39) then
  35.     set MW to the mouseLine
  36.     if MW > 0 then
  37.       set OldText to the text of member M
  38.       put str after line MW of OldText
  39.       set the text of member M to OldText
  40.     else
  41.       set the text of member M to str
  42.     end if
  43.   end if
  44. end
  45.  
  46. on Pag n
  47.   go(marker(0) - 1 + n)
  48.   set the text of field "Pag" to string(n)
  49. end
  50.  
  51. on OKNomeFile
  52.   set NF to the text of field "Nomefile"
  53.   if the last char in NF = RETURN then
  54.     set the text of field "NomeFile" to char 1 to length(NF) - 1 of NF
  55.   end if
  56.   if the text of field "ListaFile" & RETURN contains NF & RETURN then
  57.     Load()
  58.   else
  59.     new()
  60.   end if
  61.   set the text of field "Pag" to "1"
  62.   go(the frame + 1)
  63. end
  64.  
  65. on new
  66.   repeat with i = 1 to 10
  67.     set the text of field ("Pag" & i) to EMPTY
  68.   end repeat
  69. end
  70.  
  71. on save
  72.   set file to the text of field "NomeFile"
  73.   if the frame < label("Big") then
  74.     set BigString to EMPTY
  75.   else
  76.     set BigString to "Big"
  77.   end if
  78.   delNOT(file)
  79.   set xFile to new(xtra("FileIo"))
  80.   openFile(xFile, HDDir & "Passport.NOT", 0)
  81.   if Status(xFile) <> 0 then
  82.     createFile(xFile, HDDir & "Passport.NOT")
  83.     openFile(xFile, HDDir & "Passport.NOT", 0)
  84.   end if
  85.   if Status(xFile) = 0 then
  86.     readFile(xFile)
  87.     writeString(xFile, "~**~" & file & RETURN)
  88.     repeat with i = 1 to 10
  89.       set Pag to the text of field ("pag" & i & BigString)
  90.       writeString(xFile, MultiReplace(Pag, ["~", "¬ß", "\"], ["\~", "\¬ß", "\\"]))
  91.       writeString(xFile, "¬ß¬ß¬ß\\¬ß¬ß¬ß")
  92.     end repeat
  93.     writeString(xFile, RETURN)
  94.     closeFile(xFile)
  95.   else
  96.     alert("Errore di salvataggio:" && Status(xFile))
  97.   end if
  98.   set xFile to EMPTY
  99. end
  100.  
  101. on Load
  102.   set file to HDDir & "Passport.NOT"
  103.   set xFile to new(xtra("FileIo"))
  104.   openFile(xFile, file, 1)
  105.   if Status(xFile) <> 0 then
  106.     exit
  107.   end if
  108.   if findNOT(xFile) then
  109.     set s to readFile(xFile)
  110.     closeFile(xFile)
  111.     set xFile to EMPTY
  112.     repeat with i = 1 to 10
  113.       set x to offset("¬ß¬ß¬ß\\¬ß¬ß¬ß", s)
  114.       if x > 1 then
  115.         set the text of field ("pag" & i) to MultiReplace(char 1 to x - 1 of s, ["\~", "\¬ß", "\\"], ["~", "¬ß", "\"])
  116.       else
  117.         set the text of field ("pag" & i) to EMPTY
  118.       end if
  119.       delete char 1 to x + 7 of s
  120.     end repeat
  121.   else
  122.     new()
  123.   end if
  124. end
  125.  
  126. on WinMov
  127. end
  128.  
  129. on Replace Src, Fnd, rep
  130.   set ret to EMPTY
  131.   set n to the number of chars in Fnd - 1
  132.   repeat while 1
  133.     set x to offset(Fnd, Src)
  134.     if x = 0 then
  135.       exit repeat
  136.       next repeat
  137.     end if
  138.     if x > 1 then
  139.       put char 1 to x - 1 of Src after ret
  140.     end if
  141.     delete char 1 to x + n of Src
  142.     put rep after ret
  143.   end repeat
  144.   return ret & Src
  145. end
  146.  
  147. on MultiReplace Src, Fnd, rep
  148.   repeat with i = 1 to count(Fnd)
  149.     set Src to Replace(Src, getAt(Fnd, i), getAt(rep, i))
  150.   end repeat
  151.   return Src
  152. end
  153.  
  154. on findNOT xFile, NomeFile
  155.   set L to EMPTY
  156.   if voidp(NomeFile) then
  157.     set NomeFile to the text of field "NomeFile"
  158.   end if
  159.   set n to "~**~" & NomeFile & RETURN
  160.   repeat while L <> n
  161.     set L to readLine(xFile)
  162.     if (Status(xFile) <> 0) or (L = EMPTY) then
  163.       return 0
  164.     end if
  165.   end repeat
  166.   return 1
  167. end
  168.  
  169. on listNot
  170.   set ret to EMPTY
  171.   set Lst to []
  172.   set file to HDDir & "Passport.NOT"
  173.   set xFile to new(xtra("FileIo"))
  174.   openFile(xFile, file, 1)
  175.   set L to "*"
  176.   repeat while (Status(xFile) = 0) and (L <> EMPTY)
  177.     set L to readLine(xFile)
  178.     if (L <> EMPTY) and (L starts "~**~") then
  179.       delete char 1 to 4 of L
  180.       delete char -30000 of L
  181.       add(Lst, L)
  182.     end if
  183.   end repeat
  184.   set xFile to 0
  185.   sort(Lst)
  186.   repeat with L in Lst
  187.     put L & RETURN after ret
  188.   end repeat
  189.   delete char -30000 of ret
  190.   return ret
  191. end
  192.  
  193. on delNOT file
  194.   set xFile1 to new(xtra("FileIO"))
  195.   set xFile2 to new(xtra("FileIO"))
  196.   openFile(xFile1, HDDir & "Passport.NOT", 1)
  197.   createFile(xFile2, HDDir & "Temp.NOT")
  198.   openFile(xFile2, HDDir & "Temp.NOT", 0)
  199.   set L to EMPTY
  200.   set n to "~**~" & file & RETURN
  201.   repeat while 1
  202.     set L to readLine(xFile1)
  203.     if (L <> n) and (L <> EMPTY) then
  204.       writeString(xFile2, L)
  205.       next repeat
  206.     end if
  207.     exit repeat
  208.   end repeat
  209.   set L to "*"
  210.   repeat while not (L starts "~**~") and (L <> EMPTY)
  211.     set L to readLine(xFile1)
  212.   end repeat
  213.   if L <> EMPTY then
  214.     writeString(xFile2, L)
  215.     repeat while L <> EMPTY
  216.       set L to readLine(xFile1)
  217.       writeString(xFile2, L)
  218.     end repeat
  219.   end if
  220.   setPosition(xFile2, 0)
  221.   delete(xFile1)
  222.   createFile(xFile1, HDDir & "Passport.NOT")
  223.   openFile(xFile1, HDDir & "Passport.NOT", 2)
  224.   set L to "*"
  225.   repeat while (Status(xFile1) = 0) and (L <> EMPTY)
  226.     set L to readLine(xFile2)
  227.     writeString(xFile1, L)
  228.   end repeat
  229.   closeFile(xFile1)
  230.   delete(xFile2)
  231. end
  232.