Hi everybody!
I’m trying - for the first time - to use AppleScript to import QIF file in a personal FileMaker 7 database.
I’ve done some work with script editor to simulate the writing affair, with this NOT complete script, but when I put this in Filemaker, it doesn’t compile : what’s wrong with it? Is there a workaround?
Code:
on ScriviRecord(DataOperazione, Importo, Causale, Nota)
tell application “Finder”
try
–Scrivo il record nel db di FileMaker
display dialog DataOperazione & return & Importo & return & Causale & return & Nota
on error theErrorMessage number theErrorNumber
display dialog "Errore in 'ScriviRecord':" & return & theErrorMessage & " (" & theErrorNumber & ")"
end try
end tell
end ScriviRecord
on LeggiFile()
try
tell current application to activate
– Scelta file
set theFile to choose file with prompt “Scegli un File QIF:” default location (path to desktop folder) without invisibles
set fNum to open for access theFile
on error theErrorMessage number theErrorNumber
display dialog “Errore in ‘LeggiFile’:” & return & theErrorMessage & " (" & theErrorNumber & “)”
close access file theFile
return
end try
try
–Inizializzo Variabili
set theLine to “”
set DataOperazione to “”
set Importo to “”
set Causale to “”
set Nota to “”
--Leggo il contenuto del file
set ct to (get eof fNum)
repeat with i from 1 to ct
set theChar to read fNum from i to i
set theASCII to ASCII number theChar
if not ((theASCII is 13) or (theASCII is 10)) then
set theLine to theLine & theChar
else
--Linea finita
if theASCII is 13 then --return
--Riconosco il tipo di linea
set firstChar to character 1 of theLine
if ((length of theLine) > 1) then
set myData to (characters 2 thru (length of theLine) of theLine as string)
else
set myData to ""
end if
if (firstChar = "!") then
--Prima linea: da ignorare!
else if (firstChar = "D") then
--Data Operazione
set DataOperazione to myData
else if (firstChar = "T") then
--Importo
set Importo to myData
else if (firstChar = "N") then
--??
else if (firstChar = "L") then
--Causale
set Causale to myData
else if (firstChar = "M") then
--Nota
set Nota to myData
else if (firstChar = "^") then
--Scrittura Record
ScriviRecord(DataOperazione, Importo, Causale, Nota)
--Reinizializzo le variabili
set DataOperazione to ""
set Importo to ""
set Causale to ""
set Nota to ""
end if
else
--Reinizializzo la linea
set theLine to ""
end if
end if
end repeat
close access fNum
on error theErrorMessage number theErrorNumber
display dialog "Errore in 'LeggiFile':" & return & theErrorMessage & " (" & theErrorNumber & ")"
close access fNum
end try
end LeggiFile
LeggiFile()
:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(;);)
Model: Mac g5 2x2GHz
Browser: Safari 416.12
Operating System: Mac OS X (10.4)