VariablesFromFields ( )

Function stats

Average user rating
37
102
9999
Support
FileMaker 8.0 +
Date posted
05 December 2008
Last updated
02 September 2010
Version
Recursive function
Yes

Author Info
 Fabrice

74 functions

Average Rating 4.4

author_avatar



 

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

*/
// ===================================

 

 

 

 

 

 

 

Top Tags

Text Parsing  (33)
List  (31)
Date  (28)
XML  (26)
Format  (23)
Sql  (22)
Dev  (20)
Debug  (17)
Layout  (15)
Interface  (15)
Text  (14)
Variables  (12)
Filter  (11)
Layout Objects  (11)
Design  (10)
Array  (7)