FileMaker crash on getting recordvalue with underscores?
FileMaker crash on getting recordvalue with underscores?
- Subject: FileMaker crash on getting recordvalue with underscores?
- From: Richard Rönnbäck <email@hidden>
- Date: Tue, 13 Jan 2004 21:42:30 +0100
Yesterday I started my very first scripts with FileMaker and now I have run
in to a problem I don't know how to solve.
The script first searches the selected folder for MS Word documents and then
attempt to check if a record with that name exist or else create it.
The script below (work in progress) usually (but not always) crash when it
encounter some strings that contain underscores, has anyone got an idea why
I would be very grateful.
The event log reports:
tell application "FileMaker Pro"
get database 1
--> database "igen.fp5"
get ID of cell 1 of database "igen.fp5" whose cellValue of cell "Svkvdg"
= "Macintosh HD:Users:richardr:Documents:Adobe:Demos:Meste
kollas:Reklam_EventDemo:08_Preflight:ID2_end.indd_Folder:Links:05_Chart.doc"
create new record
create new record
end tell
The Script:
global myFoundFiles
--start log
tell application "System Events"
set theUser to full name of current user as string
end tell
set myFileNameToSearch to "*.doc"
set myFolder to alias ((path to desktop folder) as string) --& "Documents"
set mySearch to display dialog ,
"Svkning efter Word-dokument sker i mappen Dokument. Dndra genom att
klicka pe knappen nedan. Delar av filnamn kan svkas med *-tecken." default
answer myFileNameToSearch buttons ,
{"Avbryt", "Dndra svkvdg...", "Svk"} default button 3
set myFileNameToSearch to text returned of mySearch
if button returned of mySearch is "Dndra svkvdg..." then
set myFolder to (choose folder with prompt "Vdlj den mapp ddr du vill
att svkningen ska ske")
locate(myFolder, myFileNameToSearch)
else if button returned of mySearch is "Svk" then
locate(myFolder, myFileNameToSearch)
end if
repeat with theFile in myFoundFiles
set theFile to (theFile as POSIX file)
tell application "Finder"
set theFileProps to properties of file theFile
set theFileName to name of theFileProps
set theFileContainer to container of theFileProps as string
set theFilePath to theFile as string --(theFileContainer &
theFileName)
set theFilePath to (+class ktxt; of (theFilePath as record))
set theFileOwner to owner of theFileProps
set theFileGroup to group of theFileProps
set theFileModDate to modification date of theFileProps
set theFileModYear to (year of the theFileModDate) as string
set theFileModMonth to (month of theFileModDate) as number
set theFileModDay to (day of theFileModDate) as string
set theFileModDate to (theFileModYear & "-0" & theFileModMonth & "-"
& theFileModDay)
set theFileCreationDate to creation date of theFileProps
set theFileCreationYear to (year of the theFileCreationDate) as
string
set theFileCreationMonth to (month of theFileCreationDate) as number
set theFileCreationDay to (day of theFileCreationDate) as string
set theFileCreationDate to (theFileCreationYear & "-0" &
theFileCreationMonth & "-" & theFileCreationDay)
end tell
tell application "FileMaker Pro"
set myReg to database 1
tell myReg
try
set myID to (ID of cell 1 where (cellValue of cell "Svkvdg")
is theFilePath)
set myRecID to item 1 of myID
on error
set myNewRecord to create record
set myRecID to ID of myNewRecord
end try
tell record ID myRecID
if (cellValue of cell "Dndringsdatum" as string) is equal to
(theFileModDate as string) then
(* display dialog (cellValue of cell "Dndringsdatum") as
string
display dialog theFileModDate *)
else
set cellValue of cell "Dndringsdatum" to theFileModDate
tell application "Microsoft Word"
--set theFilePath to (+class ktxt; of (theFilePath
as record)) -- because can't handle Unicode
open theFilePath
set myDocText to (every text of document 1)
close document theFileName
end tell
set cellValue of cell "Textinnehell" to myDocText
set cellValue of cell "Fvrfattare" of record ID myRecID
to theUser
set cellValue of cell "Svkvdg" of record ID myRecID to
theFilePath
set cellValue of cell "Grupp" of record ID myRecID to
theFileGroup
set cellValue of cell "Dgare" of record ID myRecID to
theFileOwner
set cellValue of cell "Skapelsedatum" of record ID
myRecID to theFileCreationDate
end if
end tell
save it
end tell
end tell
end repeat
on locate(myFolder, myFileNameToSearch)
set myFolder to quoted form of (POSIX path of myFolder)
set myFolder to text 1 thru -3 of myFolder & "'" --drop final "/"
set myFoundFiles to every paragraph of (do shell script "find " &
myFolder & " -name " & myFileNameToSearch & " -type f")
end locate
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.