If the source code has a single-line comment containing "_FAF_Config_" in the form _FAF_Config_ ( option1, option2 ) That way, you won't have to figure out where best to store the data for the script just pass a resonable file name. If you do not pass an absolute path but only a file name, the file will be located inside a folder named "Storage" next to the script file. And the data stored should be kept small a few 100 bytes is okay, a path list of all found items would not be, as that could easily become megabytes of data, which the prefs system is not suited for.Īnother option would be to store data in a text file, using the faf.fileLoad and faf.fileSave functions. It could store some information in FAF's preferences, but if your script attempts this, it should take care to use a unique name for the preference key, ideally based on the name of the script, or on a reverse domain name you own. That means a script can't keep its values across multiple searches. where it stores its global properties, gets re-initialized after each search operation. A script's lifetime and storing data persistently The properties will be listed in a section further below. The one argument is an object providing access to many properties of the to-be-checked item (i.e. If string.find(diskItem.name, "good") thenīasically, you have to implement a function named match that takes one argument, and returns either true or false (returning nothing is fine, too, and is the same as returning false). For instance, if you have a file named a in that folder, you can choose it in the Find window as shown:Ī simple script that imitates the "Name contains good" rule would look like this: These are scripts that are placed into the Matching folder. Writing new scripts Scripts for matching during search Then click on the right-most pop-up menu again, where you will now find the newly installed script.Ĭhoose the script from the menu to use it with the Script rule. Matching), and make sure its name ends in Place the script into the appropriate sub folder (i.e. ( Note: In v2.4 and 2.4.1, the Script rule does not appear in the pop-up menu unless you hold down the option (⌥) key before clicking on it!) You can also reach the scripts folder by clicking on the rightmost pop-up menu for the Script rule: Matching – These are used as search rules, which you can then choose from once you select the Script matches rule. Installing scriptsįAF's AppSupport folder (which you can open by opening the menu bar, under Help, and choosing Open the AppSupport folder)Ĭontains a Scripts folder, which in turn contains sub folders for the different types of scripts: Later versions of FAF may add more scripting features, such as for displaying custom columns and more information about listed files and folders, and offering more commands in the contextual menu for found items. If you don't feel comfortable with writing script code, look below for a list of readily available scripts you can download and use, or ask me for assistance. Scripting is an advanced feature for power users. This makes it possible to create very specific and complex search rules. Starting with FAF version 2.4, FAF's search rules can be extended by writing scripts (programming code) in the Lua and JavaScript (short: JS) languages.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |