Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

Strange behavior creating alias.... long post!


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

Recommended Posts

Posted

I’m having strange problems with this “Restore Backup File” routine – any help would be appreciated!

My main database file is named “ISM Program.fp8” (I know .fp8 is not standard, don’t even ask why I have to use this..!). Each time the database is closed it saves a copy of itself named “ISM Data Backup” (no extension). This is the folder set up: (omitted HD & username, this runs on multiple computers with multiple usernames, that’s why I’m using “DesktopPath” in the AppleScript)

Main database = Users:Applications:ISM Stuff:Safety Management System:ISM Program.fp8

Backup #1 = Users:Applications:ISM Stuff:Backup:ISM Data Backup

Other Backups = Users:Applications:ISM Stuff:Safety Management System Backup:Monday:ISM Data Backup

---Tuesday:ISM Data Backup

---Wednesday:…and so on

The database Startup script checks to see if it’s filename is

“ISM Data Backup” & if it is goes to a Restore layout with options to “Restore” or “Cancel”. If the user chooses “Restore”, the following script runs:

Note: all applescript is “native”

.....

..Set Variable $PathFile = Left ( Get ( DesktopPath ) ; Length (Get ( DesktopPath )) - 8) & "Applications/ISM Stuff/Safety Management System/ISM Program.fp8"

..Save a Copy as [$PathFile ; compacted]

This applescript deletes the existing alias (on the desktop) to the ISM Program.fp8 file being replaced.

.. Perform AppleScript

.. tell application "Finder"

.. if exists fIle "Logs & Forms" of desktop then Select file "Logs & Forms" of desktop

.. delete file "Logs & Forms" of desktop

.. end if

.. end tell

Then this makes a new alias on the desktop to the new

“ISM Program.fp8” file.

.. Perform AppleScript

.. set ISMFile to (path to home folder) & "Applications:ISM Stuff:Safety Management System" as string

.. tell application "Finder"

.. make new alias file at desktop to file "ISM Program.fp8" of folder ISMFile

with properties {name:"Logs & Forms"}

.. end tell

.. Close File [Current File]

.......

All this is working as intended: If the user navigates through Finder to one of the ISM Data Backup files and double-clicks it starts, sees that it’s name is ISM Data Backup, saves a copy (or over-writes) as ISM Program.fp8, deletes the old alias and creates a new one to the correct file.

Now to the problem: I created another applescript (saved as .app on the desktop) as below:

.. set BackupPath to (path to home folder) & "Applications:ISM Stuff:Safety Management System Backup" as string

.. set StartFolderForSelection to alias BackupPath

.. tell application "Finder"

.. set FileToOpen to choose file with prompt "Open a Day Folder and select an ISM Data Backup file to Restore:" default location StartFolderForSelection without invisibles

.. open file FileToOpen

.. end tell

This shows a file open dialog so that the user can choose a backup file instead of having to navigate there manually. This also works – shows the dialog and runs the file chosen, which runs the startup script and executes the applescript to do the aliases. I can navigate manually to any one of the backup files & open repeatedly with no problems, but if I run the “choose file” applescript I get a “File not found” error (the file has been created, the applescript is not finding it..!).

What would be the difference between navigation manually and running this applescript? I’m setting an explicit path in the “make new alias” statement, but guessing that something is changing this path somewhere. I’m at a loss..!

Posted

Update on above message. tried just creating an alias to the folder containing the daily backup files - user opens the folder, double-clicks on an ISM Data Backup file and filemaker starts, saves a copy and runs the applescripts to do the aliases. This has been working but now is not! Works sometimes, though. Now what..!!

This topic is 5903 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.