Ooops, sorry, I'm using Filemaker Pro 8.5 with Windows XP
To create a script, pull down the script menu and select "manage scripts" or "script manager" (whatever they called it in your version).
Then click "New" to open the script editor and start a new script.
The available script steps are listed on the left hand side. Double click it to add it to your script.
Many script steps require that you specify additional details. While a script step in your script is highlighted, controls for making those selections appear at the bottom of the script editor.
A large number of script steps correspond to menu options you can select manually. If you are new to scripting, you may want to figure out how to do what you want by hand, writing down each step on a piece of paper. Then start a new script and try selecting the matching steps from your list in the same order. For simple scripts that could be all or nearly all you need do.
Phil, I was familiar with that aspect (or should I say I figured it out) but there are many scripts posted online in code form.that utilize if/then/else statements and the use of variables. I don't see any reference to that in the standard script steps offered. So how is code manually entered. The script dialog doesn't seem to allow for that.
Sorry, Phil, I now see the logical statements and the set variable statement. I'm sure I'll be able to piece something together from that.
Thanks again for your help
I think you are expecting to get a "text editor" type interface for creating a script--something that developers have asked for for many years, but this is not how the script editor has been set up. It's all "point and click" until you get to a specify button for adding the necessary calculation expressions. Then you finally get a text editor for creating such expressions.
This script, when assigned to my sort button, only sorts in one order. So far this is what I have:
Set Variable [#gSortOrder; Value:"asc"]
Sort Records [Restore] // I don't know why it says restore here. I chose "descending"
Set Variable [$gSortOrder;Value:"desc"]
Sort Records [Restore] // I don't know why it says restore here. I chose "ascending"
I also can't find where I can tell it to run without the dialog prompt. My code seems to be correct. Do I need to initialize gSortOrder somewhere? I don't think I do.
Ok, so I added a second $ before the variable name and now it works. Not sure what that rule is but I saw some code online where all variables had a double $ in front.
So the sort now works in both directions but I can't find out how to suppress the dialog.
You are missing a dollar sign. A variable with one $ is a script variable. It retains a value only as long as the script is executing. A variable with two $$ is a global variable. It will retain a value until the user closes the file. (And each user on a hosted database has their own separate set of global variables and values.) Since you are using a single variable, it disappears and its value is lost each time the script finishes execution.
And please note that accidentally misspelling a script won't prompt you with an error. FileMaker will assume that you have a different variable.
I also can't find where I can tell it to run without the dialog prompt.
When you click a script step listed as part of your script it highlights and the controls for specifying any options for it appear at the bottom of the script editor. If you click sort records, there's a check box for suppressing the dialog box that appears at the bottom of the script editor.
Thanks so much Phil for clearing up why I need the extra $. It works great now. I supressed the dialog. I just have one more thing to figure out but I'm going to do that on my own.
Which I just figured out. It wasn't resetting to the top of the list of fields but I figured that out.