Function overview
Prototype
VariablesFromFields (
)
Parameters
No parameters for this function.
Description
Tags:
variables layout Debug
Loads all current layout fields in named global variables
i.e. current layout has :
field "A" that contains "1",
field "B" that contains "2",
field "C" that contains "3"
Evaluating this function will result in 3 global variables :
$$A will contain "1"
$$B will contain "2"
$$C will contain "3"
Among other ways of evaluating this calculation, you can use :
- a Set Variable script step [ $temp ; VariablesFromFields ( ) ]
- an unstored calculation field on your layout and defined as = VariablesFromFields ( )
In this case, you will need to refresh window to load variables.
See also : VariablesFromObjects ()
Examples
Sample input
if current layout has :
field "A" that contains "1",
field "B" that contains "2",
field "C" that contains "3"
Sample output
Evaluating this function will result in 3 global variables :
$$A will contain "1"
$$B will contain "2"
$$C will contain "3"
Function code
/*
VariablesFromFields ( )
by Fabrice Nordmann
with thanks to Agnès Barouh, Ugo di Luca and Daniele Raybaudi
v2.2 : Sept 2010. Fixed another bug with double quotes (thanks Daniele)
v2.1 : Sept 2007. Fixed a bug with carriage return
v2 : no more parameter is needed (was VariableFromFields ( start ))
Loads all current layout fields in named global variables
i.e. current layout has :
field "A" that contains "1",
field "B" that contains "2",
field "C" that contains "3"
Evaluating this function will result in 3 global variables :
$$A will contain "1"
$$B will contain "2"
$$C will contain "3"
Among other ways of evaluating this calculation, you can use :
- a Set Variable script step [ $temp ; VariablesFromFields ( ) ]
- an unstored calculation field on your layout and defined as = VariablesFromFields ( )
In this case, you will need to refresh window to load variables.
This demo uses an unstored calculation : the field has to be named "VariablesFromFields, and must be put first on layout.
-----------------*/
Let([
_fields = FieldNames ( Get ( FileName ) ; Get ( LayoutName ) ) ;
_end = ValueCount ( _fields ) ;
$$cfVFF_counter = Case ( IsEmpty ( $$cfVFF_counter ) ; 1 ; $$cfVFF_counter > _end ; "" ; $$cfVFF_counter + 1 ) ;
_fieldName = GetValue ( _fields ; $$cfVFF_counter ) ;
_value = Substitute ( GetField ( _fieldname ) ; [ "\"" ; "\\\"" ] ; [ ¶ ; "\¶" ] ) ;
_textEval = "let ( $$" & _fieldname & " =" & Case ( IsEmpty ( _value ) ; "\"\"" ; "\"" & _value & "\"" ) & "; \"\")"
];
Case (
$$cfVFF_counter <= _end ; If ( _fieldName ≠ "VariablesFromFields" ; Evaluate ( _textEval ) & VariablesFromFields ( )
)
))
// ===================================
/*
This function is published on FileMaker Custom Functions
to check for updates and provide feedback and bug reports
please visit http://www.fmfunctions.com/fid/102
Prototype: VariablesFromFields( )
Function Author: Fabrice (http://www.fmfunctions.com/mid/37)
Last updated: 02 September 2010
Version: 1.2
*/
// ===================================
/*__LITBR__VariablesFromFields ( )__LITBR__by Fabrice Nordmann__LITBR__with thanks to Agnès Barouh, Ugo di Luca and Daniele Raybaudi__LITBR____LITBR__v2.2 : Sept 2010. Fixed another bug with double quotes (thanks Daniele)__LITBR__v2.1 : Sept 2007. Fixed a bug with carriage return__LITBR__v2 : no more parameter is needed (was VariableFromFields ( start ))__LITBR____LITBR__Loads all current layout fields in named global variables__LITBR____LITBR__i.e. current layout has :__LITBR__field "A" that contains "1",__LITBR__field "B" that contains "2",__LITBR__field "C" that contains "3"__LITBR____LITBR__Evaluating this function will result in 3 global variables :__LITBR__$$A will contain "1"__LITBR__$$B will contain "2"__LITBR__$$C will contain "3"__LITBR____LITBR__Among other ways of evaluating this calculation, you can use :__LITBR__- a Set Variable script step [ $temp ; VariablesFromFields ( ) ]__LITBR__- an unstored calculation field on your layout and defined as = VariablesFromFields ( )__LITBR__ In this case, you will need to refresh window to load variables.__LITBR____LITBR__This demo uses an unstored calculation : the field has to be named "VariablesFromFields, and must be put first on layout.__LITBR__-----------------*/__LITBR____LITBR__Let([__LITBR___fields = FieldNames ( Get ( FileName ) ; Get ( LayoutName ) ) ;__LITBR___end = ValueCount ( _fields ) ;__LITBR__$$cfVFF_counter = Case ( IsEmpty ( $$cfVFF_counter ) ; 1 ; $$cfVFF_counter > _end ; "" ; $$cfVFF_counter + 1 ) ;__LITBR___fieldName = GetValue ( _fields ; $$cfVFF_counter ) ;__LITBR___value = Substitute ( GetField ( _fieldname ) ; [ "\"" ; "\\\"" ] ; [ ¶ ; "\¶" ] ) ;__LITBR___textEval = "let ( $$" & _fieldname & " =" & Case ( IsEmpty ( _value ) ; "\"\"" ; "\"" & _value & "\"" ) & "; \"\")"__LITBR__];__LITBR__Case (__LITBR__$$cfVFF_counter <= _end ; If ( _fieldName ≠ "VariablesFromFields" ; Evaluate ( _textEval ) & VariablesFromFields ( )__LITBR__)__LITBR__))__LITBR____LITBR__// ===================================__LITBR__/*__LITBR____LITBR__ This function is published on FileMaker Custom Functions__LITBR__ to check for updates and provide feedback and bug reports__LITBR__ please visit http://www.fmfunctions.com/fid/102__LITBR____LITBR__ Prototype: VariablesFromFields( )__LITBR__ Function Author: Fabrice (http://www.fmfunctions.com/mid/37)__LITBR__ Last updated: 02 September 2010__LITBR__ Version: 1.2__LITBR____LITBR__*/__LITBR__// ===================================
Login or register to comment
Create a new account with fmcustomfunctions.com or login to post a comment.