Jump to content
Server Maintenance This Week. ×

EmptyFields() returns 0/1 if object's fields have values


This topic is 4588 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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

Link to comment
Share on other sites

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 )

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

... 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 ?

Link to comment
Share on other sites

This topic is 4588 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.