home *** CD-ROM | disk | FTP | other *** search
Wrap
global fd, macfix, fileCount, fileArray, successFiles, path, database on installfont fontfile, fontName put "installFont(" & fontfile & ", " & fontName & ")" if baFontInstalled(fontfile, EMPTY) then displayMessage("Font already installed", "The font you are trying to install is already installed on your machine.") else if fd = ":" then displayMessage("Error", "We're sorry, the font install feature is only available on the PC version of this disc. Please use the download feature and install manually.") else err = baInstallFont(fontfile, fontName) if err <> 0 then case err of 1: displayMessage("Error", "A font with that name is already installed on your computer.") 2: displayMessage("Error", "The font file was not found.") 3: displayMessage("Error", "Error copying font file. You may not have permission to install fonts on this machine.") 4: displayMessage("Error", "Windows couldn't install the font.") 5: displayMessage("Error", "The font file has an invalid file name.") end case else displayMessage("Success!", "Font successfully installed.") end if end if end if end on installAllFonts put "installAllFonts()" if fd = ":" then displayMessage("Error", "We're sorry, the font install feature is only available on the PC version of this disc. Please use the download feature and install manually.") else err = 0 if displayYesNo("Install All Fonts?", "Are you sure you want this disc to install all of its fonts onto your system? The process may take a couple of minutes, please be patient. If you would like to continue, click 'Yes,' otherwise, click 'No.'") then repeat with i = 1 to count(database) entry = database[i] if baFontInstalled(the pathname & "assets" & fd & "data" & fd & "fonts" & fd & entry.fontfile, EMPTY) then nothing() next repeat end if e = baInstallFont(the pathname & "assets" & fd & "data" & fd & "fonts" & fd & entry.fontfile, entry.fontName) if e > 1 then err = err + e end if end repeat if err > 0 then displayMessage("Error", "All fonts could not be successfully installed. Some fonts may be installed, while others may not.") else displayMessage("Success!", "Fonts successfully installed.") end if end if end if end on copyFolder folderN put "copyFolder(" & folderN & ")" path = promptUserFolderPath(stripPath(convertFileDelimiter(folderN, "/", fd), fd)) if path = 0 then fileCopyError(path, EMPTY) else errCount = 0 successFiles = 0 file = convertFileDelimiter(folderN, "/", fd) if fd = "\" then baCreateFolder(path & fd & stripPath(file, fd)) end if if fd = ":" then if ((the environment).osVersion contains "10") or ((the environment).osVersion contains "11") then Ok = baXCopy(file, path, "*", "Always", 1) else Ok = baXCopy(file, path & fd & stripPath(file, fd), "*", "Always", 1) end if else Ok = baXCopy(file, path & fd & stripPath(file, fd), "*", "Always", 1) end if if Ok <> 0 then displayError("I was unable to copy the files successfully.") else if fd = ":" then fList = baFileList(path, "*.*") baSetFilePermissions(path & ":", "u", "rwx") baSetFilePermissions(path & ":", "g", "rwx") baSetFilePermissions(path & ":", "o", "rwx") repeat with i = 1 to fList.count thisFile = path & ":" & fList[i] baSetFilePermissions(thisFile, "u", "rwx") baSetFilePermissions(thisFile, "g", "rwx") baSetFilePermissions(thisFile, "o", "rwx") end repeat end if displayMessage("Success!", "The files were copied successfully.") end if end if end on copyFile fileN put " PATH - " & stripPath(convertFileDelimiter(fileN, "/", fd), fd) path = promptUserPath(stripPath(convertFileDelimiter(fileN, "/", fd), fd)) if (fileN contains ".jpg") and not (path contains ".jpg") then path = path & ".jpg" else if (fileN contains ".pdf") and not (path contains ".pdf") then path = path & ".pdf" end if end if if path = 0 then fileCopyError(path, EMPTY) else errCount = 0 successFiles = 0 file = convertFileDelimiter(fileN, "/", fd) put "source file = " & file put "dest path = " & path if fd = ":" then if ((the environment).osVersion contains "10") or ((the environment).osVersion contains "11") then Ok = baCopyFile(file, path, "Always") else Ok = baCopyFile(file, path & fd & stripPath(file, fd), "Always") end if else Ok = baCopyFile(file, path, "Always") end if if Ok <> 0 then fileCopyError(path, translateBaCopyFileError(Ok)) else success() end if end if end on fileCopyError p, err if err <> EMPTY then displayError("I was unable to copy all the files successfully." && err) else displayError("I was unable to copy all the files successfully.") end if end on promptUserFolderPath fileN if fd = ":" then if ((the environment).osVersion contains "10") or ((the environment).osVersion contains "11") then return fileSaveAs(fileN, "Choose a folder to save the folder, and click 'Save'.") else p = fileSaveAs(fileN, "Choose a folder to save the folder, and click 'Save'.") if p <> 0 then return stripEnd(p, fd) else return 0 end if end if else p = fileSaveAs(fileN, "Choose a folder to save the folder, and click 'Save'.") if p <> 0 then return stripEnd(p, fd) else return 0 end if end if end on promptUserPath fileN if fd = ":" then if ((the environment).osVersion contains "10") or ((the environment).osVersion contains "11") then return fileSaveAs(fileN, "Choose a folder to save the file(s), and click 'Save'.") else p = fileSaveAs(fileN, "Choose a folder to save the file(s), and click 'Save'.") end if else p = fileSaveAs(fileN, "Choose a location and folder name, and click 'Save'.") if p <> 0 then return p else return 0 end if end if end on success me displayMessage("File copied", "File copied successfully.") end on displayError Msg alertObj = new(xtra("MUI")) alertInitList = [#buttons: #Ok, #title: "Error", #message: Msg, #movable: 1] if objectp(alertObj) then result = alert(alertObj, alertInitList) case result of 1: return 1 end case end if alertObj = VOID 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) case result of 1: return 1 end case end if alertObj = VOID end on displayYesNo title, Msg alertObj = new(xtra("MUI")) alertInitList = [#buttons: #YesNo, #title: title, #message: Msg, #movable: 1] if objectp(alertObj) then result = alert(alertObj, alertInitList) case result of 1: return 1 otherwise: return 0 end case end if end on translateBaCopyFileError errNum case errNum of 0: return "Copy successful" 1: return "Invalid Source file name" 2: return "Invalid Destination file name" 3: return "Error reading the Source file" 4: return "Error writing the Destination file" 5: return "Couldn't create directory for Destination file" 6: return "Destination file already exists" 7: return "Destination file is newer than the Source file" end case return EMPTY end on fileSaveAs 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 aMuiObj = VOID end on convertFileDelimiter fileString, oldDelimiter, newDelimiter numchars = fileString.char.count repeat with i = 1 to numchars if fileString.char[i] = oldDelimiter then put newDelimiter into fileString.char[i] end if end repeat return fileString end on stripPath fileString, delimiter x = the itemDelimiter the itemDelimiter = delimiter fileN = item the number of items in fileString of fileString the itemDelimiter = x return fileN end on stripEnd fileString, delimiter x = the itemDelimiter the itemDelimiter = delimiter fileN = fileString delete item the number of items in fileN of fileN the itemDelimiter = x return fileN end