I want to create a field in a database the contains links to multiple files on my Mac. What is the easiest way to accomplish this?
The field would be a text field containing the paths to those files. The OpenAnything statement in a procedure, would be used to open those files.
As for populating that field with those paths, the easiest way would depend on how the files were organized on your hard drive. If they are all in one folder, you might want to look at the filecatalog( function, and the ImportText statements.
If a data cell in the data sheet is open for editing, you can drag an icon from the Finder to it, and the path to that file or folder will be written automatically in that data cell.
Thanks for your help. Will give this a try.
With your help I was able to populate a text list object with the contents of a folder. I used the listfiles function. Thanks for pointing me in the right direction.
Now, suppose I have a text list object with 5 files. Is there a way for me to double click on one of the files to open it? Or do I need to select 1 file on the list and use a button to open the file?
A text list object, like any other object, can trigger a procedure when it is clicked. If you only want that procedure to execute following a double click, you would begin that procedure with
if info("modifiers") contains "doubleclick"
and end it with
endif
The code for opening the file would lie between them.
I will try to use open anything but I donāt know how to select the desired line in the text list object.
Where do I go to learn about this? Willing to purchase the tutorial, just donāt know which one is appropriate.
Thanks again for your help.
When you click on an item in the list, it will place that item in the field or variable that you setup to receive your selection. Your OpenAnything statement will use that field or variable in its formula.
This help page goes into specific detail about how to access the selected item.
Thanks to you and @Dave I have this working. Appreciate it
One last question today:
Text List Options
Value: targetfile
Formula
filecatalog(ā~/Desktop/MyFolder")
Procedure
if info(āmodifiersā) contains ādoubleclickā
openanything targetfile else
endif
If I use filecatalog( in the formula, the Text List Object shows the full path and opens the file when I double click.
If I use listfiles in the formula, it shows the file name and it doesnāt open the file when I double click.
Is there a way for the Text List Object to show only the file name (instead of the entire path) but also allow it to open the file when double-clicked?
If the folder is ~/Desktop/MyFolder and targetfile contains the file name, then you would open the file with
openanything "~/Desktop/MyFolder/" + targetfile
This works great. Opens up a lot of possibilities for me. Thank you.
I have changed things to allow my text list object to be associated with each record. Here is what Iām currently doing:
Field in Database
linkedfiles
Text List Object Options
Value: targetfile
Formula
listfiles(linkedfiles)
Procedure
if info(āmodifiersā) contains ādoubleclickā
openanything linkedfiles + targetfile
endif
This works fine if I have a path entered in the field: linkedfiles. If the field: linkedfiles is empty the text list object shows the contents of the folder where my database is stored. I can do a workaround by entering a path to an empty folder in the field: linkedfiles in every record where I want the text list object to be empty, but is there a more elegant way to do this? I tried to figure this out myself over the weekend but Iāve been unsuccessful. Any help is appreciated.
How about:
Formula
?(linkedfiles = "","",listfiles(linkedfiles))
if info(āmodifiersā) contains ādoubleclickā and linkedfiles ā ""
openanything linkedfiles + targetfile
endif
Beautiful. This works great. I put this part into āFormulaā and the other into āProcedureā.
I would never have figured this out. Appreciate your help And thank you to the others.
- Edited to correct my terminology - said ācodeā when I meant 'formula".