home *** CD-ROM | disk | FTP | other *** search
/ Yolanda Bergman's Good Health, Great Food / GoodHealth.iso / pc / yolanda.dxr / Internal_45.ls < prev    next >
Encoding:
Text File  |  1998-03-11  |  2.7 KB  |  90 lines

  1. on parsePrint startCast
  2.   global gFileIn, gScreen
  3.   set gFileIn to new(xtra("fileio"))
  4.   set fname to displayOpen(gFileIn)
  5.   openFile(gFileIn, fname, 1)
  6.   if not objectp(gFileIn) then
  7.     exit
  8.   end if
  9.   set the itemDelimiter to " "
  10.   set castline to 1
  11.   set currentCast to 1
  12.   repeat while 1
  13.     set LineIn to readLine(gFileIn)
  14.     if LineIn = EMPTY then
  15.       exit repeat
  16.     end if
  17.     set LineOut to parseLine(LineIn)
  18.     put LineOut into line castline of field currentCast of castLib "Recipe Text Files"
  19.     delete line 2 of field currentCast of castLib "Recipe Text Files"
  20.     put currentCast
  21.     set currentCast to currentCast + 1
  22.   end repeat
  23.   put "ALL DONE!  ALEX IS A CHEESEBALL!"
  24.   set gFileIn to EMPTY
  25. end
  26.  
  27. on combineLists someText, aMember
  28.   if someText = EMPTY then
  29.     exit
  30.   end if
  31.   if the castType of member aMember of castLib "database" = #text then
  32.     set originalText to the text of member aMember of castLib "database"
  33.     put "combining " & the number of lines in originalText & " of original text"
  34.     repeat with i = 1 to the number of lines in originalText
  35.       set originalLine to line i of originalText
  36.       if originalLine > EMPTY then
  37.         put originalLine into line i of someText
  38.       end if
  39.     end repeat
  40.   end if
  41.   put someText into field aMember of castLib "database"
  42.   put "Just wrote " && the number of lines in someText && "lines in cast " && aMember
  43. end
  44.  
  45. on parseLine theLine
  46.   set save to the itemDelimiter
  47.   set the itemDelimiter to TAB
  48.   set n to the number of items in theLine
  49.   set newLine to item 1 of theLine
  50.   repeat with i = 2 to n
  51.     set aChunk to item i of theLine
  52.     if (aChunk > EMPTY) and (aChunk <> RETURN) then
  53.       set token to char 1 to 4 of aChunk
  54.       if (token = "#VID") or (token = "#PIC") or (aChunk contains "Δí") then
  55.         delete char 1 to 5 of aChunk
  56.         set newTok to parseToken(value(aChunk))
  57.         set aChunk to token & "/" & newTok
  58.       end if
  59.       put "," & aChunk after newLine
  60.     end if
  61.   end repeat
  62.   set the itemDelimiter to save
  63.   return newLine
  64. end
  65.  
  66. on parseToken dataname
  67.   global gScreen
  68.   if listp(dataname) then
  69.     set datalist to dataname
  70.     repeat with listitem = 1 to count(datalist)
  71.       set dataname to getAt(datalist, listitem)
  72.       setAt(datalist, listitem, value(string(parseToken(dataname))))
  73.     end repeat
  74.     return value(string(datalist))
  75.   else
  76.     if char 1 of string(dataname) = "Δí" then
  77.       delete char 1 of dataname
  78.     end if
  79.     set m to the number of member dataname
  80.     if m > 0 then
  81.       return the memberNum of member dataname
  82.     else
  83.       if dataname <> 0 then
  84.         put "Bad name:" && dataname && "on screen" && gScreen
  85.       end if
  86.       return 0
  87.     end if
  88.   end if
  89. end
  90.