home *** CD-ROM | disk | FTP | other *** search
- on removeDuplicates
- global aList, newList
- set aList to fileToList()
- set newList to []
- repeat with i in aList
- if getPos(newList, i) then
- nothing()
- next repeat
- end if
- add(newList, i & RETURN)
- end repeat
- listToFile(newList)
- end
-
- on removeDuplicatesString string
- global aList, newList
- set aList to stringToList(string)
- sort(aList)
- set newList to []
- repeat with i in aList
- if getPos(newList, i) then
- nothing()
- next repeat
- end if
- add(newList, i)
- end repeat
- listToFile(newList)
- end
-
- on removeSortedDuplicates
- global aList, formatted
- set aList to fileToList()
- set formatted to []
- set lastOne to EMPTY
- repeat with i in aList
- if not (i = lastOne) then
- set lastOne to i
- add(formatted, i)
- end if
- end repeat
- listToFile(formatted)
- end
-
- on interlace
- global aList, list1, list2, interlaced
- set list1 to fileToList()
- set list2 to fileToList()
- set lineNum to 0
- set interlaced to []
- repeat with i in list1
- set lineNum to lineNum + 1
- set aLine to line 1 of i
- repeat with j in list2
- if j = EMPTY then
- exit repeat
- end if
- set anIngredient to line 1 of j
- if aLine contains anIngredient then
- add(interlaced, lineNum & "@" & j)
- end if
- end repeat
- end repeat
- listToFile(interlaced)
- end
-
- on idize
- global aList, list1, list2, interlaced
- set list1 to fileToList()
- set list2 to fileToList()
- set lineNum1 to 0
- set lineNum2 to 1
- set interlaced to []
- repeat with i in list1
- set lineNum1 to lineNum1 + 1
- set anID to line 1 of i
- repeat while 1
- set aLine to getAt(list2, lineNum2)
- set aLineNum to the number of words in aLine
- if word 1 of aLine = lineNum1 then
- add(interlaced, anID & word 2 to aLineNum of aLine & RETURN)
- set lineNum2 to lineNum2 + 1
- next repeat
- end if
- exit repeat
- end repeat
- end repeat
- listToFile(interlaced)
- end
-
- on separateFile
- global aList, formatted
- fileToList()
- sort(aList)
- set lastOne to "A"
- repeat with i in aList
- if not (char 1 of i = lastOne) then
- set lastOne to char 1 of i
- next repeat
- end if
- put i after field ("ingredients-" & lastOne)
- end repeat
- end
-
- on fracToFloatPars
- global aList, formatted
- set formatted to []
- set lineNum to 0
- repeat with aLine in aList
- set lineNum to lineNum + 1
- set first to offset("@", aLine) + 1
- set second to offset("@", char first to length(aLine) of aLine) + first - 2
- set quantity to char first to second of aLine
- set word1 to word 1 of quantity
- if word1 contains "-" then
- set dash to offset("-", word1)
- set quan1 to char 1 to dash - 1 of word1
- set quan2 to char dash + 1 to length(word1) of word1
- put ".0" after quan1
- put ".0" after quan2
- set floatQuantity to value(quan1) + value(quan2)
- else
- put ".0" after word1
- set floatQuantity to value(word1)
- end if
- add(formatted, lineNum & "@" & floatQuantity & RETURN)
- end repeat
- listToFile(formatted)
- end
-
- on singleify
- global aList, formatted
- set i to 0
- set iNum to count(aList)
- set lastNumber to 0
- set checkNumber to 1
- set formatted to []
- repeat while i <= iNum
- set i to i + 1
- set aLine to getAt(aList, i)
- if aLine = EMPTY then
- exit
- end if
- set number to char 1 to offset("@", aLine) - 1 of aLine
- if (number <> lastNumber) and (number = checkNumber) then
- add(formatted, aLine)
- set checkNumber to checkNumber + 1
- set lastNumber to number
- next repeat
- end if
- if number <> lastNumber then
- add(formatted, checkNumber & "@" & RETURN)
- set checkNumber to checkNumber + 1
- set i to i - 1
- end if
- end repeat
- listToFile(formatted)
- end
-
- on numberFile
- set aList to fileToList()
- set lineNum to 0
- set numbered to EMPTY
- repeat with anItem in aList
- set lineNum to lineNum + 1
- put lineNum & "@" & anItem after numbered
- end repeat
- writeFile(numbered)
- end
-
- on changeIngredients
- global newIngredients
- set ingredients to fileToList()
- set newIngredients to EMPTY
- repeat with aLine in ingredients
- if aLine contains "(" then
- set part1 to char 1 to offset("(", aLine) - 2 of aLine
- set part2 to char offset(")", aLine) + 1 to length(aLine) of aLine
- put part1 & part2 after newIngredients
- next repeat
- end if
- put aLine after newIngredients
- end repeat
- writeFile(newIngredients)
- end
-
- on lineToline
- global newText, list1, list2
- set list1 to fileToList()
- set list2 to fileToList()
- set newText to EMPTY
- set lineCount to count(list1)
- set lineNum to 0
- repeat with i = 1 to lineCount
- set standard to line 1 of getAt(list1, i)
- set id to line 1 of getAt(list2, i)
- put id & "@" & standard & RETURN after newText
- end repeat
- writeFile(newText)
- end
-
- on checkMeta aWord
- global newText, list1
- set newText to EMPTY
- repeat with i in list1
- set at to offset("@", i)
- set id to char 1 to at - 1 of i
- set match to id & "@" & aWord & RETURN
- if (match <> i) and (i contains aWord) then
- put match after newText
- end if
- end repeat
- put newText after field "foo"
- beep()
- end
-
- on checkMetaList aList
- global newText, list1
- set newText to EMPTY
- repeat with i in list1
- set at to offset("@", i)
- set id to char 1 to at - 1 of i
- set food to char at + 1 to length(i) of i
- repeat with aWord in aList
- if food = (aWord & RETURN) then
- set match1 to id & "@" & "shellfish" & RETURN
- put match1 after newText
- end if
- end repeat
- end repeat
- put newText after field "foo"
- beep()
- end
-
- on replaceStandard
- global newText, list1, gStandardIDDB, standards
- set list1 to fileToList()
- set standards to value(field "standardIDDB")
- set newText to EMPTY
- repeat with i in list1
- set at to offset("@", i)
- set recipe to char 1 to at of i
- set standard to char at + 1 to length(i) - 1 of i
- set id to getaProp(gStandardIDDB, standard)
- if id > 0 then
- put recipe & id & RETURN after newText
- else
- put standard, id
- end if
- setaProp(standards, standard, "gone")
- end repeat
- writeFile(newText)
- end
-
- on standardsNotUsed
- global standards, newText
- set num to count(standards)
- set newText to EMPTY
- repeat with i = 1 to num
- set id to getAt(standards, i)
- set ingredient to getOne(standards, id)
- if id <> "gone" then
- put id && ingredient & RETURN after newText
- end if
- end repeat
- writeFile(newText)
- end
-
- on removeStandards
- global list1, list2, newText
- set list1 to fileToList()
- set list2 to fileToList()
- repeat with i in list1
- set id to integer(word 1 of i)
- if id > 0 then
- setAt(list2, id, "removed")
- end if
- end repeat
- writeFile(listToString(list2))
- end
-
- on standardToCollate
- global newText, list1, gStandardIDDB, standards
- set list1 to fileToList()
- set categories to value(field "categoryIDDB")
- set newText to EMPTY
- repeat with i in list1
- set at to offset("@", i)
- set recipe to char 1 to at of i
- set standard to char at + 1 to length(i) - 1 of i
- set standardID to getaProp(gStandardIDDB, standard)
- set category to getaProp(categories, standardID)
- put recipe & category & RETURN after newText
- end repeat
- writeFile(newText)
- end
-