Jump to content
Server Maintenance This Week. ×

Filemaker 10 and Applescript not working need help


This topic is 5404 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies

I'm having troubles with Filemaker 10 and applescript. When we use Filemaker 7 all was good, but now with 10 can't figure out why applescript wont read db table and gather information to proceed with task.

I highlighted in red below the part of script I cant get to work.

Here's the code below from Applescript

[color:red]

property dataText : ""

property hexList : ""

property noRecordList : {}

property masterList : ""

property ScanNBRList : {}

property containerList : ""

property tempContainer : ""

tell application "Finder"

set theDate to (current date)

set theMonth to month of theDate as number

set theDay to day of theDate as number

set theYear to year of theDate as number

set shortDate to (theMonth as string) & "/" & (theDay as string) & "/" & (theYear as string)

set destinationParent to "xxx:xxxx:xxxx:xxxx:xxxx:xxxx:"

set workingFolder to choose folder with prompt "Select your image folder."

display dialog "Enter the Catalog Number" default answer ""

set catNumber to text returned in result

set folderList to list folder workingFolder

set AppleScript's text item delimiters to ""

set oldDelim to AppleScript's text item delimiters

repeat with x in folderList

set AppleScript's text item delimiters to "."

set x to x as string

set theBeg to text item 1 of x

set AppleScript's text item delimiters to oldDelim

if length of theBeg ≥ 8 then

set scanNBR to characters 1 thru 8 of theBeg as string

set testString to characters 3 thru 8 of scanNBR as string

try

set testString to testString as number

if ScanNBRList does not contain scanNBR then

set ScanNBRList to ScanNBRList & scanNBR

end if

end try

end if

set AppleScript's text item delimiters to oldDelim

end repeat

end tell

tell application "FileMaker Pro"

activate

if (exists database "NewItemMaster") = false then getURL "FMP7://xxx.xxx.xx.xxx/NewItemMaster.fp7"

if (exists window "CatItemImages") = false then getURL "FMP7://xxx.xxx.xx.xxx/CatItemImages.fp7"

[color:red]tell window "CatItemImages"

try

delete every request

end try

try

create new request

end try

repeat with z in ScanNBRList

set z to z as string

set field "SCAN_NBR" of request 1 to z as string

tell document 1 to find

try

set HexDir to cellValue of cell "HexDir" of current record as string

copy z to the end of containerList

copy HexDir to the end of containerList

copy containerList to the end of hexList

on error

copy z to the end of noRecordList

display dialog (z as text) & "This Image Did Not Work. Please Check Number."

end try

end repeat

end tell

end tell

--make a list of image file aliases and the corresponding hex directory

tell application "Finder"

set workingFolder to workingFolder as text

repeat with thisItem in folderList

set thisItem to thisItem as string

repeat with thatItem in hexList

set scanName to item 1 of thatItem as string

if thisItem begins with scanName then

set hexLocation to item 2 of thatItem as string

set imageFile to workingFolder & thisItem as alias

copy imageFile to the beginning of tempContainer

set imageDestination to destinationParent & hexLocation as alias

copy imageDestination to the end of tempContainer

copy tempContainer to the end of masterList

set textRecord to shortDate & "," & thisItem & "," & hexLocation & "," & catNumber as string

if dataText is "" then

set dataText to dataText & textRecord

else

set dataText to dataText & return & textRecord

end if

end if

end repeat

end repeat

activate

display dialog "I'm about to begin copying images to the backup. It might not look like I'm doing much, but I am. Don't touch anything until I tell you to, unless you want to die!" buttons {"OK"} giving up after 5

repeat with elAsso in masterList

set copyMe to item 1 of elAsso

set toHere to item 2 of elAsso

duplicate copyMe to toHere with replacing

set label index of copyMe to 6

end repeat

set theDesktop to desktop as alias

if exists file ((theDesktop as text) & "dataimport") then

delete file ((theDesktop as text) & "dataimport")

set textFile to (make new file at theDesktop with properties {name:"dataimport"})

else

set textFile to (make new file at theDesktop with properties {name:"dataimport"})

end if

end tell

tell application "TextEdit"

open {textFile as alias}

set text of document 1 to dataText

save document 1

close document 1

quit

end tell

set noUpload to ""

--FTP portion of script using Fetch

tell application "Fetch"

activate

make new transfer window at beginning with properties {hostname:"xxx.xxx.xx.xxx", username:"xxxxxx", password:"xxxxx", initial folder:"/xxx/xxx/xxx/xxx/xxx/xxx/xxx/", authentication:SFTP, encrypt:true}

repeat with eachItem in masterList

try

set imageFile to item 1 of eachItem

set destString to item 2 of eachItem as string

set oldDelim to AppleScript's text item delimiters

set AppleScript's text item delimiters to ":"

set remoteHexDir to text item -2 of destString

set AppleScript's text item delimiters to oldDelim

set destinationPath to dirString & remoteHexDir

put into remote folder destinationPath item imageFile format Automatic without uniquename

on error

if noUpload is "" then

set noUpload to noUpload & (imageFile as string)

else

set noUpload to noUpload & return & (imageFile as string)

end if

end try

end repeat

end tell

tell application "Fetch"

activate

make new transfer window at beginning with properties {hostname:"xxx.xxx.xxx.xx", username:"xxxxx", password:"xxxxx", initial folder:"/xxx/xxx/xxx/xxx/xxx/xxx/xxx/", authentication:SFTP, encrypt:true}

repeat with eachItem in masterList

try

set imageFile to item 1 of eachItem

set destString to item 2 of eachItem as string

set oldDelim to AppleScript's text item delimiters

set AppleScript's text item delimiters to ":"

set remoteHexDir to text item -2 of destString

set AppleScript's text item delimiters to oldDelim

set destinationPath to dirString & remoteHexDir

put into remote folder destinationPath item imageFile format Automatic without uniquename

on error

if noUpload is "" then

set noUpload to noUpload & (imageFile as string)

else

set noUpload to noUpload & return & (imageFile as string)

end if

end try

end repeat

end tell

tell application "Finder"

activate

display dialog "Image Discombobulator has finished. Enjoy your day!" giving up after 3

end tell

[color:red]

Any help getting this script working would be great!

Thank you,

Anthony

Link to comment
Share on other sites

This topic is 5404 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.