Newbies Pepperoncino Posted February 4, 2006 Newbies Posted February 4, 2006 Hi folks! Since I am new to this forum, please forgive my rudeness if this query looks too obvious. I have a bibliographical Database containing titles of texts included in the Chinese Buddhist Canon. What I am trying to do is to have a button that opens the corresponding text file. The standard procedure for doing this seems to be to create a button that uses the "Send Event" function. Then, following the "Specify" button I select from the menu "Send the event with ." I also choose the to choose the Target Application "TextEdit.app". The whole Event thus is displayed as: Send Event ["TextEdit.app"; "aevt"; "odoc"; "file:taisho_files/TSD_082_/" & taisho::File_name] File_name is the field variable containing the name of the file, a four-digit number with the extention ".txt", contained in the database "taisho". Now, the relative path (taisho_files/TSD_082/) has been checked using the "Document" feature instead of "Calculation". TextEdit will lauch, but displays an error message saying for instance: "File "taisho_files/TSD_082/2597.txt" does not exist" If there is only one fixed file chosen with the "Document" feature, it will find it without a glitch! I have tried everything my imagination could provide, including a different text editor (Jedit X) specialized in UTF-8 texts, but to no avail. If you could give me a hint, I would really appreciate. Thanks in advance for your time. P.S. I could provide screenshots if it is useful.
Søren Dyhr Posted February 4, 2006 Posted February 4, 2006 (edited) Couldn't these texts live in a containerfield instead? What the user then can do is to press a button containing this one-liner: Export Field Contents[ What it does it that it takes a lot of troubles in relative path calculations out of it, the issue is that filemaker in a networked solution can't live with OS-level filesharing because the concurrency is the no 1 source for file corruption, so the path should be different. In the dialog are you abel to assign it to the browsing tool as well. The script could then be dependant on the OS the user is sitting at, it would be daft to assign a windows specific app. for opening when at a mac. --sd Edited February 4, 2006 by Guest Full of typos, but I was urged away all in a sudden!
Newbies Pepperoncino Posted February 4, 2006 Author Newbies Posted February 4, 2006 Dear Søren, Thanks a lot for your quick reply and for the great suggestion. It is indeed a nice idea that would prevent problems linked with the location of these files. It will, however, imply a lot of work, since I will need to import 3118 text files into the container field. I guess there is no other way than to do it manually. The size of these files (a total of about 300 MB for the 3118 texts) might also make the database become a little "heavy," but I will definitely give it a try. I shall report if this method proves satisfactory, and if I survive to this additional work... Thanks again.
comment Posted February 4, 2006 Posted February 4, 2006 I am curious - does the following not work in a networked solution? 1. Store only a reference to the file in a container field; 2. Double click the container (or use Go to Field [select/perform ; container]) to open the file in its native application. I believe this should also work with a calculation field (result is container) = File Path.
Søren Dyhr Posted February 4, 2006 Posted February 4, 2006 Yes Michael it has escaped me, must be some time since last time I turned this stone. It's even better because the desktop doesn't get littered by all the attempts. So indeed use the checkbox!!! The tying files with containerfield ought to be an applescripted solution by all means. If I only could remember where I saw it??? --sd
Søren Dyhr Posted February 4, 2006 Posted February 4, 2006 I have now struggled for hours, and can help thinking that the appleevents.fp7 reference we all have in our installed folders, have got it wrong somewhere when FMInc suggests that you can get the reference of a file into a container field like this: tell application "FileMaker Pro Advanced" set cell 1 of record 1 to file ((choose file) as string) end tell This is going to be the burdening kind of storage, and not as they state the one as if the checkbox is checked. Further more if you issue a: class info of cell 1 with both types of storage are they absolutely identical - in my huble opinion?? --sd
comment Posted February 4, 2006 Posted February 4, 2006 I am not sure what you are trying to do. I believe Pepperoncino already has the file path in the record. So all he needs to do is create a calculated container, instead of a variable. I use Insert File[] to get a file into a container (reference only OR the actual file), so I don't know why AS would be necessary here - unless you want to bring over an entire folder. Strange that FMP will not let you that with "files" (not pictures/text).
Søren Dyhr Posted February 5, 2006 Posted February 5, 2006 unless you want to bring over an entire folder Wasn't it likely?? This is what I seeked to solve: I will need to import 3118 text files into the container field. I guess there is no other way than to do it manually. --sd
Newbies Pepperoncino Posted February 5, 2006 Author Newbies Posted February 5, 2006 I am not sure what you are trying to do. I believe Pepperoncino already has the file path in the record. So all he needs to do is create a calculated container, instead of a variable. This is fantastic! It works perfectly, and is so simple, so elegant! Thank you so much for taking the time to give this explanation. My question has thus been fully addressed and answered. Let me summarize the conclusion in a language accessible to beginners. 1) Create a Calculation field (I called it "File_container"). 2) Click the . 3) At the bottom choose "Calculation result is ." 4) On the Calculation line, insert the field that contains the relative path of the file you want to insert (I called it "Path_name"). Then close the whole thing, and you are all set! The container field will display the icon of the file, and double-clicking on this icon will open the text file with the default application. With my deep gratitude for sparing me vain hours of work.
Wim Decorte Posted February 5, 2006 Posted February 5, 2006 Only Windows needs to use the "send event" for this. On Mac you have an additional script step that has no equivalent on Windows: Perform AppleScript. That may be a whole lot easier than using the "send event".
comment Posted February 5, 2006 Posted February 5, 2006 Wasn't it likely?? This is what I seeked to solve: Turns out that it isn't required here, but if you manage to pull it off, I'd be interested.
Søren Dyhr Posted February 5, 2006 Posted February 5, 2006 (edited) Come again??? 10-20 seconds to link a reference to a text by hand, might be next to nothing for say hundred files, not that I in any way suspect you lack anything at all in the math. dept. but lets say that it was 3600 files, that gives if we say we're quick and links 6 per minute that it takes 600 minutes for the entire set of texts. Divided by 60 minutes per hour.... No I really hoped that Fenton or BruceR jumped in and gave a better method in AS ...it seems like an error that the applescript implementation can't see the distinctions we see and uses a default, that burdens the import with raw data and no references. I said your suggestion was good, because it prevented the littering of the desktop with used files. But it seems not yet posible to dynamicly to link with $variables to a arbitrary document, except perhaps with GetURL, but it would require that you setup your browser with helper applications to make it cope with it. --sd Edited February 5, 2006 by Guest
Fenton Posted February 5, 2006 Posted February 5, 2006 I'm not sure where we are in the thread. But here is an example file that uses AppleScript and the script Set Variable to set up an Insert File, either Referenced or Embedded from an entire Folder (chosen). It is definitely FileMaker 8 ONLY. Insert_Folder_Files.fp7.zip
Søren Dyhr Posted February 5, 2006 Posted February 5, 2006 I havn't thought that a variable could be used in that list - this is great - Thanks for the input. It does make it irrelevant that the Applescript implementation lacks the distinction ...or could you make it behave?? --sd
comment Posted February 5, 2006 Posted February 5, 2006 I think that to get a reference only, you could try giving the Appplescript a TEXT field as the target. On the whole, it looks like Filemaker's Insert > File... is different from both Filemaker's Set Field and Applescript's 'set cell'. Perhaps a 'do menu' could work here?
AnneES Posted February 6, 2006 Posted February 6, 2006 I'm not sure why this did not work for me. I have a field which stores the filepath/name. (inserted using Troi file plugin) I created the calculation field as helpfully described by Pepperoncino here. The calculation/container field displays the filepath/name; not an icon; does not lauch with double click. I tried exporting the field contents and only the filepath/name were exported... I have used Troi to attach and launch files from outside the database but I want to use the FMP8 insert file (reference only) feature as it is easier for my users. I have several thousand records with attached documents, pdfs, xls etc which is why this calculation would be sooo helpful. Any idea of what I am doing wrong? thanks for any feedback Anne Skinner
Søren Dyhr Posted February 6, 2006 Posted February 6, 2006 Hi Anne You expess it better than me, it was the discovery I made! There seems ot be no other way than what Fentons template does. --sd
Søren Dyhr Posted February 6, 2006 Posted February 6, 2006 I think that to get a reference only, you could try giving the Appplescript a TEXT field as the target. But it makes the double clicking disappear, say if you make an "as text" clause in the end of the line - it just makes the path show up as text in the container field ...and not the icon as we would expect. --sd
comment Posted February 6, 2006 Posted February 6, 2006 I am guessing that the file path as inserted by the plugin is not what Filemaker requires for this. AFAIK, the path must look like one of these: ABSOLUTE PATH: filemac:/MacintoshHD/Users/thisUser/Documents/someFolder/someFile.txt RELATIVE PATH: file:../Documents/someFolder/someFile.txt I suspect you don't have the "filemac:/" prefix in your path string.
comment Posted February 6, 2006 Posted February 6, 2006 I meant get the path into a text field - then use a calculated container, which you can double click.
Fenton Posted February 6, 2006 Posted February 6, 2006 Anne, what does your calc result look like? Duplicate the calc and make the result "Text" to see it (and check that the original calc has "Container" as the result). And is this a networked situation? In which case the full path has to include the volume name of a shared volume. By the way, the Troi File plug-in, despite being a FileMaker plug-in, uses the OS file paths, Mac or Windows, NOT the Filemaker syntax paths. So you have to convert them; mostly ":" to "/" on a Mac, but it must begin with the prefix "filemac:/" or filewin:/"
AnneES Posted February 6, 2006 Posted February 6, 2006 Fenton's solution would be wonderful if I wanted to create a series of NEW records based on a folder of files. Unfortunately what I need to do is keep the files attached to existing records. thinking, thinking...
AnneES Posted February 6, 2006 Posted February 6, 2006 The problem was my syntax - as per Fenton's suggestion, I replaced the Mac syntax, inserted "filemac" and Hooray, ended up with a clickable icon. Thanks so much for the help - you are all such clever people. AS
Newbies Pepperoncino Posted February 7, 2006 Author Newbies Posted February 7, 2006 I'm not sure where we are in the thread. But here is an example file that uses AppleScript and the script Set Variable to set up an Insert File, either Referenced or Embedded from an entire Folder (chosen). It is definitely FileMaker 8 ONLY. Thank you for the great script, which is a real source of inspiration. Meditating on this piece suggests a lot of hints on how to harness the power of FM and AppleScript. This thread seems to have unexpectedly provided some very interesting replies, and I am grateful to all of those who provided their help and insight.
Recommended Posts
This topic is 6866 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