Software Venture Consulting

FileMaker Pro downloads & Resources
FileMaker Custom Functions
FileMaker Web Viewer Examples
FileMaker Pro & Lasso Consulting
Training
FileMaker Books
FileMaker Articles
FileMaker Error Reference

Free Web Tools
Free FileMaker Tools

Personal Pages
Videos
Adventures
Links

Shopping Cart
Shopping Cart

Search:

Free Newsletter
Signup


Contact


Privacy Policy



FileMaker is a registered trademark of FileMaker, Inc. in the U.S. and other countries.

 

 FileMaker Pro Custom Functions

List  |  Show Random  |  Upload  |  Add This to Your Site

VarListCreatorPro ( VarType, VarName, VarValue, Mode)

Rate this function:  

RatingRatingRatingRatingRating
  Average rating: 4.3  (3 votes)
  Discuss this Custom Function

Joseph Arzate, IT Professional Consultants
http://itprofessionalconsultants.net

Creates a variable by name or a the result of a calculation and can maintain a unique List.

Sample Input:
VarListCreatorPro ( "", "MyList", "Apple¶Orange", "")
Sample Output:
Creates a GLOBAL Variable called "$$MyList" with values:

Apple
Orange

AND creates a second variable called "$$MyList.count" with the value:
2


 Then copy & paste into FileMaker Advanced's Edit Custom Function window.

Click here to copy To Clip Manager if you have myFMbutler's Clip Manager installed

Description:

INSTRUCTIONS / COMMENT / EXAMPLES - BEGIN
______________________________________________________________________
IT Professional Consultants Inc.
www.itprofessionalconsultants.net
Author: Joseph Arzate (2.19.11)
----------------------------------

Function: VarListCreatorPro ( VarType, VarName, VarValue, Mode)

----------------------------------
[VarType] - Boolean value (0 or NULL for GLOBAL and 1 for SESSION). By Default "0" or NULL ("") value will instruct the function to create a Global ($$) variable. Sending a "1" will create a Session ($) variable.
[VarName] - The name you want the variable to be called. You must comply with FM existing variable naming convention and restrictions. No special characters.
[VarValue] - The value you want to add/remove to the variable. Send it a "List" of values separated by ¶.
[Mode] - List or Single/Replace value operation ("L" or NULL "" ) for unique List operation. "S" for single value, replacing the variable with the value submitted.

----------------------------------

Function Result 1: Adds/Removes/Replaces a value for the purpose to create/modify a Session or Global variable list or single value, using a text value provided. Multiple values can be sent at once using the FM functions such as "List" or "ValueList". Can be used anywhere a calculation can be defined.

Function Result 2: Creates a variable affixed with ".count" that will display the number of values in that variable list.

----------------------------------

Why: Needed an easy way to create and manage session and global variables as a list with a name as a result of a calculation. You can create variables using native FileMaker function values as the variable names, which will make the code portable. For example you can use the Get(CurrentLayoutName) as your variable name.

The function can operate with NULL value ("") for parameters, as a default mode operation. Examples below will display the use of this default operation as "Syntax1 [Alternate]"

----------------------------------
DESCRIPTION :
This custom function can create a session or global variable by name. FM only allows a variable name to be defined by hard coding it's name (as of FM16). When you call this function for the first time, it will create two variables. One is the value you sent to it and the second variable with a count of the number of values in the list. When you call this function to an already existing variable that contains a list of values, it will analyze the values you are sending to it and compare it to the existing values. If the value already exists it removes the value, if it's not on the list, it adds to it. It's main purpose was to store a List of values to a custom variable name and to facilitate the use of the "LIST" function FM Pro provides to add and remove values. However, it can also be used to store values using standard FM functions. This function helps promote modular "Portable" code.

Advance Description: You can use this function to create a variable by the result of a calculation, so long as the variable value name does not contain an illegal character. You can send the function a list of values and the function will add / remove any existing values, thus, maintaining a custom unique list. The function creates a second variable with ".count" as it's name with number of values the variable contains.

----------------------------------
How to call it in a script:

Use the "Set Variable" script step and name it whatever you want, I usually use "$Temp". Enter the function in the "Value" and once you call it you will end up with a Global or Session based variable with the values you sent to it.

-----------------------------------
Examples
-----------------------------------
Example A - Global List Variable:
Syntax1: VarListCreatorPro ( 0 , "MyList" , "Apple¶Oranges", "L" )
Syntax1 [Alternate]: VarListCreatorPro ( "" , "MyList" , "Apple¶Oranges", "" )
Result1: Creates a Global variable "$$MyList" and appends to the list the value "Apple¶Oranges", if the value already exists in the "$$List" variable the function will remove "Apple" from the list.
Result2: Creates a Global variable "$$MyList.count" with the number of values that exist in "$$MyList". Will return "2" if two values are on the list.

Example A.2 - Global unique LIST Variable:
Syntax1: VarListCreatorPro ( 0, "List" , "1¶2¶3", "L")
Syntax1 [Alternate]: VarListCreatorPro ( "" , "List" , "1¶2¶3", "")
Result1:Creates a Global variable "$$List" with the value "1¶2¶3", if any of the values already existed in the "$$List" variable the function will remove the matching numbers from the list.
Result2: Creates a Global variable "$$List.count" with a value of "3".

Example B - Global replace Value Variable:
Syntax: VarListCreatorPro ( 0 , "List" , "ABC", "S")
Syntax1 [Alternate]: VarListCreatorPro ( "" , "List" , "ABC", "S")
Result1:Creates a Global variable "$$List" with the value "ABC" and replaces any value that may existed in the variable.
Result2: Creates a Global variable "$$List.count" with a value of "1".
NOTE: For Single value or Replace operations you must specify the "S" parameter or else the function will attempt to maintain a unique list.

Example C - Session List Variable (same as Example A, except it's a Session variable [$] vs Global [$$] ):
Syntax1: VarListCreatorPro ( 1, "List", "Orange", "L")
Syntax1 [Alternate]: VarListCreatorPro ( 1, "List", "Orange", "")
Result1: Creates a Session variable named "$List" and will append the value "Orange" to the list. If the value "Orange" already exists in "$List" the function will remove "Orange" from the list.
Result2: Creates a Session variable "$$List.count" with a value of "1" when "Orange" is the only value in the variable.

Example D - Session Single Value Variable:
Syntax: VarListCreatorPro ( 1, "List", "Orange¶Apple", "S")
Syntax1 [Alternate]: None. You must use the "1" for a Session variable and you must use "S" to use replace the variable with the value your sending it.
Result1: Creates a Session variable named "$List" and will replace the variable with the value "Orange¶Apple" and replaces any value that may existed in the variable.
Result2: Creates a Global variable "$List.count" with a value of "2" when "Orange" is the only value in the variable.

Example E - Session List Value Variable:
Syntax: VarListCreatorPro (1, "List", "Grape¶Orange", "L")
Syntax1 [Alternate]: VarListCreatorPro (1, "List", "Grape¶Orange", "")
Result1: Replaces the value of a global variable with the value "Grape¶Orange". Any existing value in this variable will be replaced by the value sent to it.
Result2: Creates a Global variable "$$List.count" with a value of "2" when "Grape¶Orange" are the values in the variable.

Example F - Clear Variable:
Syntax1: VarListCreatorPro ( 0 , "List", "" , "" )
Syntax1 [Alternate]: VarListCreatorPro ( "" , "List", "" , "" )
Result: Erases the values in the Global variable named "$$List"
Result2: Creates a Global variable named "$$List.count" with a value of 0.

Special Note: This is a very powerful function that can promote 'Modular' portable scripting, if this function has saved you time or made your life easier in your commercial solution and you wish to make a donation feel free to send to PayPal: itpc.josepha@gmail.com :) - Enjoy!

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:

There are no comments yet. Be the first to post a comment about this Custom Function! Please try to keep it brief & to the point. Anyone can post:

Your Name:
City/Location:
Comment:
characters left. If you paste in more than 1500 characters, it will be truncated. Discuss the function - advertisements and other useless posts will be deleted.
Answer 4 + 8 =
Search for Custom Functions:

Custom Functions Widget
Download the Custom Function Dashboard Widget for OS X
Keep all the latest Custom Functions right at your fingertips!

Newest Custom Functions:

1. decFromHex ( hexValue )
  (Mon, Oct 16, 12:34pm)
2. MonthYearList ( startmonth ; startyear ; numbermonth ; short )
  (Mon, Oct 16, 3:38am)
3. ErrorDescription ( errorNumber )
  (Wed, Sep 27, 2:51am)
4. decodeEntities (text)
  (Wed, Sep 27, 1:22am)
5. HexidecimalToNumber ( HexidecimalValue ; counter )
  (Mon, Sep 25, 12:39pm)
6. FixedFieldConverter ( Fieldname ; f1 ; f2 ; f3 ; f4 ; f5 ; f6 ; f7 ; f8 ; f9 ; f10 ; f11 ; f12 ; f13 ; f14 ; f15 ; f16 ; f17 ; f18 ; f1
  (Fri, Sep 15, 12:34pm)
7. ShannonEntropy ( text )
  (Thu, Sep 07, 5:59am)
8. LetterCount ( text ; summary )
  (Thu, Sep 07, 5:53am)

RSS Feed of Custom Functions