October 6, 201114 yr Name & Parameters: EmptyFields ( object ; counter ) Description: This function is meant to take a tab name as the object parameter and return a 1 if any of the named fields are empty, 0 if they have values. The counter parameter should be 0. Recursive: Yes Sample Input: "tab.Science" ; 0 Results: Formula: /*Empty Fields ( object ; counter ) by David Jondreau, www.wingforward.net This function is meant to take a tab name as the object parameter and return a 1 if any of the named fields are empty, 0 if they have values. */ Let([ objects = GetLayoutObjectAttribute ( object ; "containedObjects" ) ; end = ValueCount ( objects ) ; thisObject = GetValue ( objects ; counter ) ; thisType = GetLayoutObjectAttribute ( thisObject ; "objectType" ) ; isField = ( thisType = "field" ) ; empty = isField and IsEmpty ( GetLayoutObjectAttribute ( thisObject ; "content" ) ) ; result = Case ( IsEmpty ( end ) ; 0 ; empty ; 1 ; counter >= end ; 0 ; EmptyFields ( object ; counter + 1 ) ) ]; result ) Credits: David Jondreau
October 6, 201114 yr Author I don't trust $vars not to "step on each other" . If this function evaluates at the same time as another using the same named $var, I don't know if that will screw it up. I suppose I could use a $var with a reasonably unique repetition.
October 6, 201114 yr If this function evaluates at the same time as another using the same named $var... I can't think about such situation, each calculation field evaluates its calc and then pass to the next. ( naturally you'll have to set the $var to empty at the end of the calc )
October 6, 201114 yr Who create those functions ? The creator knows wich is the name of his $var. And even if I want to call a CF created by anyone else, I first go to see which is the ( eventually ) used $var.
October 6, 201114 yr Author OK....what about scripts? If I use a $var in a script that has the same name as the $var in the function, that may cause errors. Functions should stand on their own and not require cross-checking. I just can't think of a safe way to use $vars as counters. I'd love to, but I don't see it.
October 6, 201114 yr Author The file I made is an abstraction, but maybe it will help. If I use a $counter variable in a script, and a $counter variable in a function that is called in the script, we get incorrect results. counter.fp7.zip
October 7, 201114 yr May be that we have to use some custom name for the $var, something like $cf_counter, but just to joke and experiment I modified you file. ;) counterMod.zip
October 10, 201114 yr Author A function should stand independent. I have yet to find a way of using a $var in a function that avoids possible cross-contamination with script variables. In your example, if $go or $old is used in script with the function, we'll get bad results.
October 10, 201114 yr Do you think it would be safe in this way? Let( $_cf_$counter = $_cf_$counter + 1 ; $_cf_$counter & If ( $_cf_$counter < 10 ; ¶ & counter ; Let ( $_cf_$counter = "" ; "" ) ) )
October 10, 201114 yr Author Now that's clever...That's better (can't use the script step Set Variable[]), but the problem is still that $vars are scoped to a script not a calc and there can be cross-pollination. A function should be self-contained, but with $vars you can influence them from the outside.
October 10, 201114 yr ... and something like this ? Let( $.$counter = FilterValues ( $.$counter & "¶**ThisIsACounter**" ; "**ThisIsACounter**" ) ; ValueCount ( $.$counter ) & If ( ValueCount ( $.$counter ) < 10 ; ¶ & counter ; Let ( $.$counter = "" ; "" ) ) ) Naturally the string could be any combination of chars. Why would someone set an $var to be such strange ?
Create an account or sign in to comment