accuraterealty Posted June 10, 2008 Posted June 10, 2008 For my database I also now need to do basic applescipts. I have just started today, However, I have hit a roadblock. I need to know how to write out a file's path name. I thought it would be {imac HD/Users/Mddharma}, but when i try to compile it, It gives me a syntax error saying "Expected “,” or “}” but found identifier." and it has "HD" Highlighted, but that is part of my hard-drives name. Thanks for the help
Fenton Posted June 10, 2008 Posted June 10, 2008 There are 2 kinds of OS file paths possible in Mac OS X. Which you use depends on which application or tool is running it. Each can be converted to the other when necessary. But basic AppleScript uses the old style Mac path, which is colon-separated, and includes the drive name. So, if "imac HD" is your actual drive name, then: "imac HD:Users:Mddharma:" would be your home folder (assuming that's what "Mddharma" is. AppleScript also knows the locations of a lot of folders by its reserved name. Using that syntax produces an alias to the path, ready to use; though you might want to get as text instead (if you want to add more to it): path to home folder -- result: alias "Macintosh HD:Users:fej:" path to home folder as Unicode text -- "Macintosh HD:Users:fej:" (P.S. Starting with Leopard you only need to say "as text", it will automatically be Unicode text; though the older syntaxes will still work.)
accuraterealty Posted June 11, 2008 Author Posted June 11, 2008 Thanks for help, however, my script is a failure. It will not work, I no not what I have done wrong. Here's what I need the apple script to do. When I save a record in Filemaker as a PDF, I want Finder to create a Folder, With that Contacts name, that correspond to that record. And then for Filemaker to place that PDF in that Newly created Folder An example: I have a contact named Bob. For Bob's File, I Fill out my input page, and then go to his Lease Agreement, a layout, which is filled out because of the input page. So I click a button, I assume it would be a button, and then my apple script activates. It would take Bob's name, since it's reading that from the "Name" Field, and the apple script would create a folder called "Bob", and place the PDF of the Lease Agreement in the Folder it just created. ( And the script would create the folders all in the same place, I do not need to change that ) I hope you understand.... Thanks
Fenton Posted June 11, 2008 Posted June 11, 2008 (edited) There are two options for the Perform AppleScript script step in FileMaker. One is to put the the entire AppleScript in a FileMaker calculation, then use the (•) Calculated AppleScript option. The other is to put the text of the AppleScript in the (•) Native AppleScript box. In this case I used the calculation method, mostly because it is simpler if the AppleScript is not complex and is mostly reading values from FileMaker fields. It also requires less context specification within AppleScript, as FileMaker gets the values. It is more difficult to write/edit in some ways however, because of escaping the quotes and adding the line endings. There is a Create Folder button, if you just want to see it work. It checks if the folder is there, creates it if it's not. That's really the only AppleScript in the file. The rest is just FileMaker, Variable path and Save As PDF. The Export runs the Create Folder AppleScript. Then it runs Save As PDF, using the same path to the folder, the file name you specify, adding a date stamp. Save As PDF does the found set. You likely don't want that. You'd want a routine to isolate the current record. But that's another question -] It also just puts these folders on the Desktop. You'd likely want a more specific location. But that's also another question, as I don't know where you'd want them. Folder_from_field.fp7.zip Edited June 11, 2008 by Guest
accuraterealty Posted June 13, 2008 Author Posted June 13, 2008 Thanks for the continuing help, I need all I can get. I believe you've answered a lot of my questions from previous posts, I appreciate it. Alex
accuraterealty Posted June 20, 2008 Author Posted June 20, 2008 I have one question about this folder-creating thing-a-ma-jig. If i have 3 or 4 records, it will PDF all of them. How do I change it so that it only creates a folder and PDF of the record I am on. Thanks
Fenton Posted June 20, 2008 Posted June 20, 2008 There are several ways to do this. Some of them have weaknesses in a high-volume network environment, or use New Window, hence are kind of "flashy" (which is not a good thing in FileMaker). So, since you ask me, I'll show you my favorite method. It uses an insanely clever (hence created by someone else -) method of temporarily saving the found set. It exploits a basic ability of the relational engine, to transfer the found set of a table occurrence to a disconnected table occurrence of the same base table. We use this all the time in: Go To Related Record [ relationship; any layout of the target table ] What this guy (please speak up if it's you) realized was that if you: Go To Related Record [ table occurrence you're on; a disconnected table occurrence of the same table ] Then it will transfer the current found to that other TO, pretty much instantly. Then you return to the layout you were on, and do whatever to the found set. The "saved" found set can be recovered at any time during the current session by doing the reverse. Go to Layout [ Found set layout, of found set table occurrence ] Go To Related Record [ main table occurrence of table; whatever layout you were on ] The "whatever layout you were on" is the tricky part. You need to capture it (or part of it) in a script parameter. Then branch the returning Go To Related Record accordingly. Yeah, way more than you ever wanted to know. But this Save and Restore Found Set can be used in any script that would otherwise disturb the found set. You can bring back the saved found set over and over again, if necessary. Or manually, instead of using New Window (which is actually safer for manual messing about). In this case I saved the found set. Then I went to a self-relationship on a unique key (just using the name in this case, as it's all I've got). This gives you one and only one record. Then do the folder, Save as PDF. Then restore the found set. Very fast. Does not flash. Does not mess with the found set (much -). Folder_from_field_FS.fp7.zip
accuraterealty Posted July 2, 2008 Author Posted July 2, 2008 I have horrible reply time....but either way, I'm in to process of reconstructing it in my database, so thanks
Recommended Posts
This topic is 5987 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 accountSign in
Already have an account? Sign in here.
Sign In Now