1 of 2 people found this helpful
On page 2, you will find the explanation, part of is:
Next, we’ll define an auto-enter calculation for handle:
Let ( [
_trigger = Self ;
$$move_id = category
The purpose of this calculation is to populate the global variable $$move_id with the
current record’s category. The first line, _trigger = Self, ensures that the calculation
will run any time the field is modified. Finally, we return id to ensure that handle will
always have something in it. This is crucial, since users can’t drag from an empty
container. We’ll set the font size to 300 so that the text won’t appear in the small graphic
Very interesting file.
Thanks, but it does not answer the question. PDF does not explain it.
An Auto-Enter calculation is recalculated any time a referenced field (that isn't in a related table) is changed. So the _trigger = Self line simply has the Auto-Enter calculation reference the field itself so that the calculation is recalculated any time the field's value changes (in this case, when you drop something into the container). Dropping something into the container changes the value of the field. Then, by virtue of the _trigger = Self line, the Auto-Enter calculation is triggered to set the global variable (and change back the value of the field) so that seemingly the value never changes.
If you take out that line, the Auto-Enter calculation won't run when the value is changed (and you'll see a value change when dropping text into the container). Essentially the line's sole purpose is to flag to FileMaker that the Auto-Enter calculation needs to run whenever the value is changed. It isn't a hidden feature of FileMaker, it is simply a creative use of how Auto-Enter responds to field references.
Does that explanation help?
2 of 2 people found this helpful
I don't know if you are familiar with the Let() function: to sum up, in the first part (between [ ]), you can set local variables that are used to make some calculation. Here _trigger is a local variable that will go away once the Let is finished. But $$move_id is a global variable that is set here. This one will continue living after the Let (that's perfectly Ok). The second part of the Let returns a value. In this occurrence, the returned value is id, which is a field in the same table, Move. So handle is set to the value of id. The important part is that $$move_id is set to the new category where the item is dragged.
It may be hard to understand what going on. If you have FileMaker Pro Avanced, the start the debugger and see what happens in what order. That will help you understand the chain of events. If you look at the Layout in Layout mode, don't believe what you see: if you move around what's in the portal, you will find out that a portal row is made of two fields on top of each other. The field at the bottom has the trigger that moves the item.
Yes, this is what I have found interesting. Apart from other type of variables ($_local, $$_global ) Let function allows a third type of script variable that calls functions like _trigger = Self.
Self = "Return the contents of the field/object"
As my understanding it does not just ensure the recalculation but ensures to return the original content of the field but it replaces the content.
When the cursor dragged on the targeted field it picks up (copy) the new content (category). It replaces the original content into an other one. OK I got it ! It returns the content of the object!
The variable does not need to be a member of an equation/calculation in the script. The variable affects the whole script and ensures that the $_moveid = category has to return the content of the targeted field where the cursor is placed.
I think the most difficult to understand how Self works. We need something that helps to copy the new content of the targeted field something like GetLayoutObject Attribute function.
I think it is clear, now, thanks for the help.