Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

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

Hi David

why not use an $var instead of the counter parameter ?

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

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 )

  • Author

What about when one function calls another?

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.

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

I think that you are speaking abstractly.

Could you make a tiny file ?

  • 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

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

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

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 = "" ; "" ) )

)

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

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.