Understanding @commands

I am trying to understand the order execution, have read the help and all forum posts concerning this issue, but still cant seem to find the logic behind them.

I ceated a new empty form containing a button with the follow code:

@Command( [EditDocument]; “1” );

@SetField(“SomeField”;“Value”);

Also adding the following, with obtained result:

1)@If(@Command([FileSave]);@Command([CloseWindow]);“”) → [OK]

2)@If(@Command([FileSave]);@Command([FileCloseWindow]);“”) → [save prompt]

3)@If(@Command([FileSave]);@PostedCommand([CloseWindow]);“”) → [save prompt]

4)@If(@Command([FileSave]);@PostedCommand([FileCloseWindow]);“”) → [save prompt]

5)@If(@PostedCommand([FileSave]);@PostedCommand([CloseWindow]);“”) → [OK]

6)@If(@PostedCommand([FileSave]);@PostedCommand([FileCloseWindow]);“”) → [OK]

It does not make any sense to me.

I did all those tests because I had a more complex specific problem, where in a reponse document, between the FileSave and CloseWindow, I set a field of the parent document.

In some scenarios, the client is crashing or I get save prompt. I finally had to use SaveOption to resolve this, which I guess you should not have to.

Those command certainly dont seem to work as documented…

Thanks all.

Subject: Understanding @commands

Read “Order of evaluation for formula statements” in the designer help. All your test are executed in the order that is described there.

  1. Close window is the equivalent of FileCloseWindow and it occurs in the order as it appears

  2. FileCloseWindow is a command that is executed at the end of the formula

3, 4) A postedcommand is always executed at the end of the formula

5, 6) Postedcommands are executed in the order that they appear (at the end of a formula)

So, although I agree that commands can give a surprising result, the results of your tests really are the same as documented.

Regards,

René

Subject: RE: Understanding @commands

I did read this help document, thats why I made this post.

In all my examples, nothing is done between the save and the close… Why do you believe that 2,3,4 should give a save prompt?

Subject: RE: Understanding @commands

That’s why Commands make people absolutely crazy!When I posted my answer it made 100% sense to me. Now I see it is rubbish…

I myself always use the postedcommands for save & closing. I never tried to understand why. This morning I really thought I figured it out but I really didn’t. Sorry.

Subject: Understanding @commands

What happens when you add a single editable field to the form and set the value of that via the button? Does the behaviour of the @commands change at all?

On the surface, it looks like the save prompts occur when there is a mixture in the if statement of immediately executed @commands with those which run at the end of a formula?

Paul.

Subject: RE: Understanding @commands

The behaviour is the same when using a field on the form.

My test case is very simple and it is possible to find a logic for this specific case.

But if you have a more complex formula sequences (f.ex. if you do things before/between/after the save and close like run macros, modify other documents etc.), it can get very nasty (client crash) and it means basically trial/error to find something that works…