home *** CD-ROM | disk | FTP | other *** search
- global debug, isProjector
-
- on cgiSafe theString
- repeat with i = 1 to the number of chars in theString
- if "$&/.:'~`!*(){;}[]^%#?\|=+" & QUOTE & RETURN contains char i of theString then
- delete char i of theString
- i = i - 1
- next repeat
- end if
- if " " contains char i of theString then
- put "_" into char i of theString
- end if
- end repeat
- return theString
- end
-
- on isCgiSafe theString, can_contain
- repeat with i = 1 to the number of chars in theString
- if " $&/.:'~`!*(){;}[]^%#?\|=+" & QUOTE & RETURN contains char i of theString then
- if can_contain <> VOID then
- if can_contain contains char i of theString then
- else
- return 0
- end if
- next repeat
- end if
- return 0
- end if
- end repeat
- return 1
- end
-
- on stripspaces string
- repeat with i = 1 to the number of chars in string
- if " " contains char i of string then
- delete char i of string
- i = i - 1
- end if
- end repeat
- return string
- end
-
- on lower str
- x = the number of chars in str
- repeat with i = 1 to x
- z = charToNum(char i of str)
- if (z < 91) and (z > 64) then
- put numToChar(z + 32) into char i of str
- end if
- end repeat
- return str
- end
-
- on upper str
- x = the number of chars in str
- repeat with i = 1 to x
- z = charToNum(char i of str)
- if (z > 96) and (z < 123) then
- put numToChar(z - 32) into char i of str
- end if
- end repeat
- return str
- end
-
- on testDiskRW testPath
- global myFile
- failed = 0
- if objectp(myFile) then
- myFile = 0
- end if
- myFile = new(xtra("fileio"))
- createFile(myFile, testPath & "testy.txt")
- openfile(myFile, testPath & "testy.txt", 0)
- writeString(myFile, "abc test string 123")
- closeFile(myFile)
- myFile = 0
- if objectp(myFile) then
- myFile = 0
- end if
- myFile = new(xtra("fileio"))
- if the machineType = 256 then
- setFilterMask(myFile, "All files,*.*,Text files,*.txt")
- else
- setFilterMask(myFile, "TEXT")
- end if
- openfile(myFile, testPath & "testy.txt", 1)
- if status(myFile) = 0 then
- filecontents = readFile(myFile)
- else
- failed = 1
- end if
- closeFile(myFile)
- myFile = 0
- if filecontents <> "abc test string 123" then
- failed = 1
- end if
- if objectp(myFile) then
- myFile = 0
- end if
- myFile = new(xtra("fileio"))
- openfile(myFile, testPath & "testy.txt", 0)
- delete(myFile)
- closeFile(myFile)
- myFile = 0
- if failed = 1 then
- return "fail"
- else
- return "ok"
- end if
- end
-
- on fieldToFile fileName, fieldname
- dput("fieldToFile : " & fileName & " <- " & fieldname)
- myFile = new(xtra("fileio"))
- if the machineType = 256 then
- setFilterMask(myFile, "All files,*.*,Text files,*.txt")
- else
- setFilterMask(myFile, "TEXT")
- end if
- if not voidp(fileName) and not (fileName = EMPTY) then
- createFile(myFile, fileName)
- openfile(myFile, fileName, 2)
- if status(myFile) = 0 then
- repeat with i = 1 to the number of lines in field fieldname
- writeString(myFile, line i of field fieldname & RETURN)
- end repeat
- end if
- closeFile(myFile)
- end if
- myFile = 0
- end
-
- on fileToField fileName, fieldname
- dput("fileToField : " & fileName & " -> " & fieldname)
- myFile = new(xtra("fileio"))
- if the machineType = 256 then
- setFilterMask(myFile, "All files,*.*,Text files,*.txt")
- else
- setFilterMask(myFile, "TEXT")
- end if
- if not voidp(fileName) and not (fileName = EMPTY) then
- openfile(myFile, fileName, 1)
- if status(myFile) = 0 then
- filetext = readFile(myFile)
- filetext = lf2cr(filetext)
- put filetext into field fieldname
- end if
- closeFile(myFile)
- end if
- myFile = 0
- end
-
- on lf2cr str
- if not offset(numToChar(10), str) then
- return str
- end if
- str2 = EMPTY
- repeat with i = 1 to the number of chars in str
- if char i of str = numToChar(10) then
- put RETURN after str2
- next repeat
- end if
- put char i of str after str2
- end repeat
- return str2
- end
-
- on dput arg
- put arg
- end
-
- on displayString outString
- if debug then
- put outString
- end if
- end
-
- on Hang tix
- x = the timer
- repeat while the timer < (x + tix)
- nothing()
- end repeat
- end
-
- on postError string, critical
- dput("ERROR: " & string)
- z = displayError(string & RETURN & "[The Program Must Exit Now]")
- if critical and isProjector then
- return
- end if
- return 1
- end
-
- on detectQuicktime
- if not (the quickTimePresent) then
- decision = displayYesNo("In order to use this CD-ROM, you must have Quicktime Installed. Please click 'Yes' to do so and then re-launch the CD-ROM.")
- if decision then
- if the platform contains "Windows" then
- fd = "\"
- else
- fd = ":"
- end if
- open(the pathname & "Installers" & fd & "QT.exe")
- quit()
- else
- end if
- end if
- end
-
- on displayError Msg
- alertObj = new(xtra("MUI"))
- alertInitList = [#buttons: #Ok, #title: "Error", #message: Msg, #movable: 1]
- if objectp(alertObj) then
- return alert(alertObj, alertInitList)
- else
- return 0
- end if
- end
-
- on displayYesNo Msg
- alertObj = new(xtra("MUI"))
- alertInitList = [#buttons: #YesNo, #title: "Please choose Yes or No.", #message: Msg, #movable: 1]
- if objectp(alertObj) then
- return alert(alertObj, alertInitList)
- else
- return 0
- end if
- end
-
- on solicitURL defaultval
- MUIObj = new(xtra("Mui"))
- if objectp(MUIObj) then
- tell the stage
- result = GetUrl(MUIObj, defaultval, 1)
- end tell
- dput(result)
- if result <> defaultval then
- return result
- end if
- end if
- return defaultval
- end
-
- on displayMessage title, Msg
- alertObj = new(xtra("MUI"))
- alertInitList = [#buttons: #Ok, #title: title, #message: Msg, #movable: 1]
- if objectp(alertObj) then
- result = alert(alertObj, alertInitList)
- end if
- return result
- end
-
- on fileSaveAs me, fileString, prompt
- put "fileSaveAs(" & fileString & ", " & prompt & ")"
- aMuiObj = new(xtra("MUI"))
- result = FileSave(aMuiObj, fileString, prompt)
- put "returned: " & result
- if result <> fileString then
- return result
- else
- return 0
- end if
- end
-
- on toggle num
- if num = 0 then
- num = 1
- else
- if num = 1 then
- num = 0
- end if
- end if
- return num
- end
-
- on listContains theList, theItem
- listC = count(theList)
- repeat with i = 1 to listC
- if getAt(theList, i) = theItem then
- return i
- end if
- end repeat
- return 0
- end
-
- on cListContains theList, theItem
- listC = count(theList)
- repeat with i = 1 to listC
- if getAt(theList, i) contains theItem then
- return i
- end if
- end repeat
- return 0
- end
-
- on urlListContains theList, theItem
- listC = count(theList)
- repeat with i = 1 to listC
- if getname(stripExtension(getAt(theList, i))) = theItem then
- return i
- end if
- end repeat
- return 0
- end
-
- on fullUrlListContains theList, theItem
- listC = count(theList)
- repeat with i = 1 to listC
- if getAt(theList, i) = theItem then
- return i
- end if
- end repeat
- return 0
- end
-
- on timeDifference time1, time2
- return 0
- end
-
- on getname url
- Pos = 0
- repeat with i = 1 to the number of chars in url
- if char i of url = "/" then
- Pos = i
- end if
- end repeat
- if Pos then
- return char Pos + 1 to the number of chars in url of url
- end if
- end
-
- on stripExtension str
- if str contains "." then
- numchars = the number of chars in str
- repeat with i = numchars down to i
- if char i of str = "." then
- pivot = i
- exit repeat
- end if
- end repeat
- return char 1 to pivot - 1 of str
- else
- return str
- end if
- end
-
- on openWin windowName
- StageRect = (the stage).rect
- windowRect = window(windowName).sourceRect
- MiawW = getAt(windowRect, 3) - getAt(windowRect, 1)
- MiawH = getAt(windowRect, 4) - getAt(windowRect, 2)
- centerScreenH = ((getAt(StageRect, 3) - getAt(StageRect, 1)) / 2) + getAt(StageRect, 1)
- centerScreenV = ((getAt(StageRect, 4) - getAt(StageRect, 2)) / 2) + getAt(StageRect, 2)
- left = centerScreenH - (MiawW / 2)
- top = centerScreenV - (MiawH / 2)
- right = left + MiawW
- bottom = top + MiawH
- window(windowName).rect = rect(left, top, right, bottom)
- window(windowName).windowtype = 4
- open(window(windowName))
- end
-
- on waitWindow
- openWin("Progress")
- end
-
- on QuickSort list, lB, rB
- global passCtr
- lo = lB
- Up = rB
- repeat while Up > lo
- i = lo
- j = Up
- temp = getAt(list, lo)
- repeat while i < j
- sortKey = getAt(list, j)
- repeat while sortKey > temp
- j = j - 1
- sortKey = getAt(list, j)
- end repeat
- setAt(list, i, getAt(list, j))
- sortKey = getAt(list, j)
- repeat while (i < j) and (sortKey <= temp)
- i = i + 1
- sortKey = getAt(list, i)
- end repeat
- setAt(list, j, getAt(list, i))
- end repeat
- setAt(list, i, temp)
- QuickSort(list, lo, i - 1)
- lo = i + 1
- passCtr = passCtr + 1
- end repeat
- end
-