PyPop

A helper function to set FileMaker variables. The function does not appear in the list of external functions and is intented to be used solely from the plug-in itself.

Usage#Back to top

PyPop( slotNumber )

Arguments#Back to top

slotNumber

Number of the slot to pop from the cache.

Result and side effects#Back to top

The function returns whatever was put into that slot of the internal cache and clears the slot. The function may produce the following errors:

  • TypeError if slotNumber is not a number.

  • ValueError if slotNumber is less than zero, greater than the number of slots in the cache, or if the specified slot is empty.

  • Exception if it cannot convert the object in the slot into FileMaker format.

See more about errors in PyFM in documetation for PyLastError.

Discussion#Back to top

The plug-in API doesn't have a dedicated method to set a variable from within a plug-in, but has the evaluate() method, which can evaluate any FileMaker expresssion. This means we can set FileMaker variables by evaluating an expression like this:

Let( $myVar = something that returns an object from the plug-in; "" )

The PyPop() function is that ‘something.’ Internally the system works so:

  • The plug-in has a cache that can store a number of objects.

  • The developer can add an object to the cache and get back a number that identifies the position in the cache, for example, 7.

  • Now the developer can evaluate() an expression like this:

    Let( $myVar = PyPop( 7 ); "" )

    During evaluation FileMaker will call PyPop() and it will return the object in the 7th slot, which is what the developer put into it.

This is a low-level description; the plugin module actually provides more convenient set_variable() function to set a single variable and VariableSetter class to set multiple variables at once. See the plugin module for complete documentation.