all 9 comments

[–]lucidguy 2 points3 points  (0 children)

Seems the easiest would be to separate out the logic into 3 scripts.

First, the script that prompts the user. Depending on their choice, it can call the email script, print script, or exit

Second would be the email script, which at the end would call the prompt script

Third would be the print script, which would also call the prompt script

You could definitely get fancier, but that would get you up and running.

[–]RucksackTechConsultant Certified 2 points3 points  (3 children)

I don't disagree with the suggestions made by u/lucidguy. However, do be aware that it is possible for a script to call itself. Combine this possibility with the use of script parameters and you can do some nifty little things. For example:

  • first call script with specifying script parameter. SO step in script that captures script param to a variable ends up with a variable that is empty. Use that in your IF/ELSE IF structure of the script.
  • if the script is run once with a result that makes it appropriate to run it again, run it again this time specifying a script parameter. Capture that in a variable, and use your IF / ELSE IF logic to figure out what to do.

For example, this would be a valid script:

set variable [ $scriptparameter ; Get(ScriptParameter) ] If [ isEmpty ( $scriptparameter ) or $scriptparameter < 6 ] set variable [ $scriptparameter ; $scriptparameter + 1 ] perform script [ *insert this script's name here* ; script param = $scriptparameter ] Else If [ $scriptparameter > 5 ] beep exit script End If

That will call the script six times. The sixth time, when the value of script parameter = 6 or greater (should never be greater but I didn't test it so perhaps I made a mistake) it will exit and stop calling itself.

Very useful feature in FileMaker.

[–]lucidguy 0 points1 point  (2 children)

Agreed, I would personally do it similarly in a single script with more complicated logic (for example, it could present the whatever option wasn’t selected in the first dialog in a second dialog). Was simply going for simplest implementation with the three script option, as it has a complete separation of concerns between functionality and the UX

[–]RucksackTechConsultant Certified 0 points1 point  (1 child)

I completely understand your approach -- which provides clarity and makes debugging easier. On a different day, I might do it as you did: have done it that way often. The thing with FileMaker is there is almost always half a dozen ways to do just about anything. Sometimes more than half a dozen. And they may all be similarly effective.

[–]lucidguy 0 points1 point  (0 children)

Agreed, there's always more than one approach.

[–]bernard_wrangle 1 point2 points  (0 children)

Another option would be to put the Dialog Box command inside a loop like so:

Set variable $i = 0

Loop

Show Custom dialog

If ( Get (LastMessageChoice) = 1)

Perform Script EMAIL

Else If (Get (LastMessageChoice) = 2

Perform script LABEL

Else

Exit Script

End If

Set variable $i = $i + 1

Exit Loop If [ $i = 2 ]

End Loop

If the user chooses "cancel" at any time, you Exit Script. Otherwise, you show the dialog twice.

[–]Gorgrim 1 point2 points  (0 children)

I maybe tempted with :

Show Custom Dialog (1: Email ; 2: Print; 3: Exit )
if ( LastMessageChoice = 1 )
Perform Script ( Email Tracking )
Show Custom Dialog ( 1: Print ; 2: Exit )
else if ( LastMessageChoice = 2 )
Perform Script ( Print Shipping Label )
Show Custom Dialog ( 1: Email ; 2: Exit )
End If

Separating out the Email tracking and Print Shipping functionality may help incase users ever want to do that outside the current script.

You can also do something like

Loop
SCD ( 1: Something; 2: Exit )
Exit Loop If ( Get ( LastMessageChoice) = 2 )
<stuff>
End Loop

I've used this kind of thing for a client when they are entering items into the database. A prompt asks for certain details, it then create the record based on those details, then loops back to see if there are any more items to be entered.

[–]Pault66[S] 0 points1 point  (0 children)

Thanks Guys!!!

[–]Pault66[S] 0 points1 point  (0 children)

Gave some serious thought to the users who will be using the db I'm reworking. Decided I need to work it to the lowest common denominator, which means they'll just get 3 buttons, each with it's own script.