VariablesLog ( )

Function stats

Average user rating
5.0000
37
105
9999
Support
FileMaker 8.0 +
Date posted
05 December 2008
Last updated
15 May 2009
Version
Recursive function
No

Author Info
 Fabrice

74 functions

Average Rating 4.4

author_avatar



 

Function overview

Prototype

VariablesLog  ( _key;   _repetition;   _value )


Parameters

_key  


_repetition  


_value  


Description

Tags:  Variables   Debug  

Declares a named variable and log it in a 'super variable' ($$_VariablesLog) in order to pass it to another file or across user sessions.

Examples

Sample input

VariablesLog ( "myVar" ; 2 ; "Hello World !" )


Sample output

$$myVar[2] = "Hello World !"

 

Function code

/*
VariablesLog ( _key ; _repetition ; _value )
by Fabrice Nordmann

v.2.5 Dec 2008
- preserve data type in the variable, not the log. Thanks to Shawn Flisakowsky)
v.2.2, May 2008
- repetitions
v.2.1, Jan 2008
- handles quotes and double quotes
v.2.0, Sept 2007
- handles multine values if variable is declared several times (uses |#|CR|#| to display ¶ in $$_VariablesLog)

Declares a named variable and log it in a 'super variable' ($$_VariablesLog) in order to pass it to another file or across user sessions.

inspired by
VariableInitialize
Jonathan Mickelson, Thought Development Corp.
http://thought-dev.com
*/

// initialise file log
Case ( IsEmpty ( $$_VariablesLog ) ;
Let ( $$_VariablesLog = "VariablesLog for " & Get ( FileName ) & " - " & Get ( UserName ) ; "")
; "" )

&

Let ([
_repetition = Int ( GetAsNumber ( _repetition ))
; _repetition = Case ( _repetition <> 1 ; _repetition )
; _key = Case ( Left ( _key ; 2 ) <> "$$" ; "$$" & _key ; _key ) & Case ( not IsEmpty ( _repetition ) ; "[" & _repetition & "]" )
; $cf_value = _value

/* DECLARE VARIABLE */
; var = ¶ & _key & "|"
; CR = "#CR#"
; dim = Evaluate ( "let ( " & _key & "= $cf_value ; \"\")")
; $cf_value = Substitute ( $cf_value ; ¶ ; CR )

//#### is variable already logged ?
; exists = Case ( PatternCount ( ¶ & $$_VariablesLog ; var ) ; 1 ; 0 )

//#### no, it isn't
/* LOG VARIABLE */
; log = Case ( exists = 0
; Let ( $$_VariablesLog = $$_VariablesLog & var & $cf_value ; "" )
; ""
)

//#### yes, it is
/* MODIFY LOG */
; pos = Position ( ¶ & $$_VariablesLog ; var ; 1 ; 1 )
; len = Length ( var ) -1
; pos = pos + len
; end = Position ( $$_VariablesLog & ¶ ; ¶ ; pos ; 1 )
; nbchar = end - pos

; log = Case ( exists = 0 ; log ;
Let ( $$_VariablesLog = Replace ( $$_VariablesLog ; pos ; nbchar ; $cf_value ) ; "" )
) // Case
];
"")

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

    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/105

    Prototype: VariablesLog( _key; _repetition; _value )
    Function Author: Fabrice (http://www.fmfunctions.com/mid/37)
    Last updated: 15 May 2009
    Version: 1.5

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