fnSetGlobalVar ( Name; Value )
Rate this function: Average rating: 3.9 (15 votes) Discuss this Custom Function
Rob Poelking, Excelisys
http://www.excelisys.com
Dynamically sets a global variable with a single script line.
Sample Input:
| fnSetGlobalVar ( "myVar"; "myValue" ) |
|
Sample Output:
|
Description:
Allows the user to set dynamic global vars without having to explicitly script a named variable. So you can have a single line script set variable [$var] pass the parameters and create a global var on the fly or destroy it by passing the name with no value. I needed to declare a global variable in a different file and did not want to script just for that single variable. I wanted something I could reuse as needed
Note: these functions are not guaranteed
or supported by BrianDunning.com. Please contact the individual
developer with any questions or problems.
This is my Custom Function and I want to
edit it
Discuss:Make a comment about this Custom Function (please try to keep it brief & to the point). Anyone can post:
|
Newest Custom Functions:
| 1. |
Backwards( _Field ) |
| |
(Thu, May 23, 10:49am) |
| 2. |
FilteredPortalList ( fieldObjectName ; portalRow ) |
| |
(Tue, May 21, 5:33pm) |
| 3. |
ListToggle ( InList ; InValue ) |
| |
(Thu, May 16, 6:59pm) |
| 4. |
VatFormat ( vat ) |
| |
(Tue, May 14, 2:45am) |
| 5. |
CheckVatBE ( vat ) |
| |
(Tue, May 14, 2:32am) |
| 6. |
CheckIBAN (IBAN ) |
| |
(Tue, May 14, 2:24am) |
| 7. |
OrcidCheckDigit ( Orcid_id ; Result ; Iterations ) |
| |
(Wed, May 08, 1:44am) |
| 8. |
DateRangeBySpan ( Begin ; End ; Term) |
| |
(Mon, May 06, 6:53am) |
 |
|
Rob, I have taken the liberty to change the function to allow the repetition to also be specified. My changes also have it return the evaluation error code s the function result.
Many thanks for an excellent cf.
--- begin
// SetGlobalVar ( name ; repetition ; value )
// Author: Rob Poelking
// Date: 20080613
//
// Modified by Vaughan Bromfield to specify the repetition.
// The function returns the error result from the evaluationn operation
// which is zero when there is no error.
//
// This function does not check that the variable name is valid
// other than filtering out non-alphanumeric characters.
Let (
[
nameclean = Filter( name ; "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz1234567890" ) ;
repetitionclean = Int( GetAsNumber( repetition ) )
] ;
EvaluationError( Evaluate ( "Let ( $$" & nameclean & "[" & Max( repetitionclean ; 1 ) & "] = " & Quote ( Value ) & "; 0 )" ) )
) // end let
/* Notes: Allows the user to set dynamic global vars without having to explicitly script a named variable. So you can have a single line script set variable [$var] pass the parameters and create a global var on the fly or destroy it by passing the name with no value. I needed to declare a global variable in a different file and did not want to script just for that single variable. I wanted something I could reuse as needed. */
--- end
Vaughan Bromfield, Sydney, Australia
April 23, 2010 5:10pm