[proFit-list] pro Fit and Applescript…doesn't like '/' in file names
Dave Sopchak
dsopchak at enervault.com
Fri Nov 18 17:41:50 CST 2011
Hi all,
I found out the hard way that pro Fit will give an error if you're trying to save a file while running from an Applescript and the file name or path has a '/' character in it. Bug or feature?
The app itself can save files with a '/' character in the name, but I noticed on text file imports, while the data window's name has a '/' character in it, when you go to save, the '/' is converted to a '-'.
Here's some example code and a workaround…
Cheers,
Dave
set bar to (theFile as text) & ", pro fit data"
set foo to replace_chars(bar, "/", "-")
tell application "pro Fit 6.2.4"
activate
data import options mode custom headerLines 2 delimiter "*\\w" terminator "\\R" title delimiter "\\w" with copyInfo and titles
open theFile as data window
save window 1 in foo
end tell
on replace_chars(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars
More information about the proFit-list
mailing list