Code - Custom Function

ShowValueCascade ( fields ; altText )

BrianDunning.com, Brian Dunning http://www.briandunning.com/filemaker-custom-functions/list.php


ShowValueCascade ( fields ; altText )
Rate this function: Average rating: 0.0 (0 votes) Discuss this Custom FunctionShowValueCascade, IT Solutions Consulting, Inc.
http://www.itsolutions-inc.com/Filemaker
Given a text string of fields, it will return the first non-empty value, if all are empty, will return an alternate value
==================== SAMPLE INPUT AND OUTPUT ====================
INPUT
ShowValueCascade ( "Student::FirstName; Student::MiddleName; Student::NickName"; "The Student With No Name" )
OUTPUT
Lefty
==================== DESCRIPTION ====================
PURPOSE: to show the first available value from a list of fields.
SPECIAL CONSIDERATIONS: it is assumed you are pointing to fields (or parameters) and the list of fields are separated by semicolons and the whole string is encapsulated in quotes
ShowValueCascade ( "firstChoice; { secondChoice; thirdChoice; fourthChoice...}"; altText)
given the field values:
Student::FirstName = (empty)
Student::MiddleName = "Joe"
Student::NickName = "Sticky"
ShowValueCascade ( "Student::FirstName; Student::MiddleName; Student::NickName"; "The Student With No Name" ) will return "Joe" since it's first on the list
given the field values:
Student::FirstName = (empty)
Student::MiddleName = (empty)
Student::NickName = (empty)
ShowValueCascade ( "Student::FirstName; Student::MiddleName; Student::NickName"; "The Student With No Name" ) will return "The Student With No Name" all the referenced fields are empty
==================== CUSTOM FUNCTION ====================

/*

NAME: ShowValueCascade ( fields ; altText )

CREATORNAME: Chad Sager, IT Solutions Consulting, Inc.

CREATOREMAIL: chad.sager@itsolutions-inc.com

DATE CREATED: 2010-02-18

DATE LASTMODIFIED: 2010-02-18



PURPOSE: to show the first available value from a list of fields.



SPECIAL CONSIDERATIONS: it is assumed you are pointing to fields (or parameters) and the list of fields are separated by semicolons and the whole string is encapsulated in quotes



ShowValueCascade ( "firstChoice; { secondChoice; thirdChoice; fourthChoice...}"; altText)



given the field values:

Student::FirstName = (empty)

Student::MiddleName = "Joe"

Student::NickName = "Sticky"



ShowValueCascade ( "Student::FirstName; Student::MiddleName; Student::NickName"; "The Student With No Name" ) will return "Joe" since it's first on the list



given the field values:

Student::FirstName = (empty)

Student::MiddleName = (empty)

Student::NickName = (empty)



ShowValueCascade ( "Student::FirstName; Student::MiddleName; Student::NickName"; "The Student With No Name" ) will return "The Student With No Name" all the referenced fields are empty











*/







Let (

[

@length = Length ( fields );

@position = Case ( Position ( fields; ";"; 1; 1 ) > 0; Position ( fields; ";"; 1; 1 ); @length + 1 );

@firstValue = Left ( fields; @position - 1 );

@newFields = FullTrim ( Right ( fields; @length - ( @position + 1 ) ) )

];



Case (

not IsEmpty ( Evaluate ( @firstValue ) ); Evaluate ( @firstValue );

IsEmpty ( fields ); altText ;

ShowValueCascade ( @newFields ; altText )

)



)


Referring URL: 'http://www.briandunning.com/cf/1126'

Attached File:    

Screenshot:    


Keywords: ''

ClipManager: