home *** CD-ROM | disk | FTP | other *** search
- on writeFile text
- set myObj to FileIO(mnew, "?write", "fileName")
- if objectp(myObj) then
- myObj(mWriteString, text)
- myObj(mdispose)
- end if
- end
-
- on readFile
- set myObj to FileIO(mnew, "?read", "TEXT")
- if objectp(myObj) then
- return myObj(mReadToken, EMPTY, EMPTY)
- myObj(mdispose)
- end if
- end
-
- on readLine aFileName
- set myObj to FileIO(mnew, "read", the pathName & aFileName)
- if objectp(myObj) then
- return myObj(mReadLine)
- myObj(mdispose)
- end if
- end
-
- on fileToList
- global aList
- set aList to []
- set content to "dummy"
- if objectp(myObj) then
- myObj(mdispose)
- end if
- set myObj to FileIO(mnew, "?read", "TEXT")
- if objectp(myObj) then
- repeat while content <> EMPTY
- set content to myObj(mReadLine)
- add(aList, content)
- end repeat
- end if
- if objectp(myObj) then
- myObj(mdispose)
- end if
- put "file to list complete"
- return aList
- end
-
- on listToFile aList
- set file to EMPTY
- repeat with i in aList
- put i & RETURN after file
- end repeat
- writeFile(file)
- end
-
- on stringToList theString
- global aList
- set aString to theString
- set aList to []
- set num to the number of lines in aString
- repeat with i = 1 to num
- set anItem to line i of aString
- add(aList, anItem)
- end repeat
- return aList
- end
-
- on listToString aList
- global newList
- set newList to EMPTY
- repeat with i in aList
- put i & RETURN after newList
- end repeat
- return newList
- end
-
- on listToString3 aList
- global newList
- set newList to EMPTY
- repeat with i in aList
- put i & RETURN after newList
- end repeat
- return newList
- end
-
- on listToString2 aList
- global newLista
- set newList to EMPTY
- repeat with i in aList
- put i & RETURN & RETURN after newList
- end repeat
- return newList
- end
-
- on removeReturns fieldName
- set num to the number of lines in field fieldName
- set it to field fieldName
- repeat with i = num down to 1
- if line i of it = EMPTY then
- delete line i of it
- end if
- end repeat
- put it into field fieldName
- return it
- end
-
- on removeReturns2 aString
- set num to the number of lines in aString
- repeat with i = num down to 1
- if line i of aString = EMPTY then
- delete line i of aString
- end if
- end repeat
- return aString
- end
-
- on removeCarrots aString
- repeat while 1
- set Carrot to offset("^", aString)
- if Carrot then
- delete char Carrot of aString
- return removeCarrots(aString)
- next repeat
- end if
- exit repeat
- end repeat
- return aString
- end
-
- on removeSpace aString
- repeat while 1
- set space to offset(" ", aString)
- if space then
- delete char space of aString
- return removeSpace(aString)
- next repeat
- end if
- exit repeat
- end repeat
- return aString
- end
-
- on floatToFrac float
- set whole to 0
- set fraction to 0
- if float > 1.0 then
- set floatString to string(float)
- set point to offset(".", floatString)
- set whole to integer(char 1 to point - 1 of floatString)
- set float to float - whole
- end if
- if float > 0.0 then
- if float <= 0.0625 then
- set fraction to "1/16"
- else
- if float <= 0.125 then
- set fraction to "1/8"
- else
- if float <= 0.1875 then
- set fraction to "3/16"
- else
- if float <= 0.25 then
- set fraction to "1/4"
- else
- if float <= 0.3125 then
- set fraction to "5/16"
- else
- if float <= 0.33400000000000002 then
- set fraction to "1/3"
- else
- if float <= 0.375 then
- set fraction to "3/8"
- else
- if float <= 0.4375 then
- set fraction to "7/16"
- else
- if float <= 0.5 then
- set fraction to "1/2"
- else
- if float <= 0.5625 then
- set fraction to "9/16"
- else
- if float <= 0.625 then
- set fraction to "5/8"
- else
- if float <= 0.66700000000000004 then
- set fraction to "2/3"
- else
- if float <= 0.6875 then
- set fraction to "11/16"
- else
- if float <= 0.75 then
- set fraction to "3/4"
- else
- if float <= 0.8125 then
- set fraction to "13/16"
- else
- if float <= 0.875 then
- set fraction to "7/8"
- else
- if float <= 0.9375 then
- set fraction to "15/16"
- else
- set whole to whole + 1
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- if (fraction <> 0) and (whole <> 0) then
- return whole & "-" & fraction
- else
- if fraction <> 0 then
- return fraction
- else
- return whole
- end if
- end if
- end
-