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.

Featured Replies

Well hello

I am try to pass a function A as a parameter to function B. This function A will return true OR false. I want a second function B to count the number of records, based on the first function A. The condition is the function A I am trying to pass.

Problem:

The passed function A is not evaluating correctly. The condition is always being evaluated as True.

Example:

I am calling this code out of a table field(Type: formular).

Let([

expression="GetNthRecord (rekla_rt_Ersatz::Type ; start_recordno)="Loaner""



];

recordcount_on_expression ( rekla_rt_Ersatz::ID ; expression; 1 )

)




This is the function:



recordcount_on_expression ( primary_key_field ; expression; start_recordno )





If(IsValid ( GetNthRecord ( primary_key_field; start_recordno) );



case (

Evaluate("expression");



1 + recordcount_on_expression ( primary_key_field ; expression; start_recordno + 1 );

 

recordcount_on_expression ( primary_key_field ; expression; start_recordno + 1 )



)



;0)

I hope somebody has a clue. Thanks a lot

Bye

Robert

There should be no quotes around expression.

Also change your evaluate statement as follows:

Evaluate ( Substitute( expression; "start_recordno"; start_recordno )) ;

Your function can be simplified as follows:

Case ( IsValid ( GetNthRecord ( primary_key_field; start_recordno)) ;

GetAsBoolean ( Evaluate (

Substitute( expression; "start_recordno"; start_recordno )

)) +

RecordCount_on_expression ( primary_key_field ; expression; start_recordno + 1 )

)

  • Author

That did the trick. The substitute function. Great.... let me be your humble servant

And the quotes around the expression of course(they are a leftover during my tests)

But I am still kinda confused. I do not understand how the substitute function can help here. The return type is still text. So you substitute text with text ?!?!?

  • Author

I altered the function to pass actions to. Unfortunately the actions can only work with numbers and fields that contain numbers. Maybe you have an idea of how to work with strings.

lets say an action concatenates fields when condition is met.

Example: do = "table::someword &"

this doesn't work, but it would be nice ???

But so far this works:

action_on_expression ( primary_key_field ; expression ; do; start_recordno )

Example:

1.

do = "1 +"

this will just count the number of records that meet the condtion

2.

do = "Table::Amount +"

this will add up the amout of all record that meet the condition

Let([



//Austauschen des Textstrings damit es als Zahl erkannt wird 

expr=Substitute( expression; "start_recordno"; start_recordno );

action=Substitute( do; "start_recordno"; start_recordno )



];



If(IsValid ( GetNthRecord ( primary_key_field; start_recordno) );



Case (

Evaluate ( expr) ;    

Evaluate(action & recordcount_on_expression ( primary_key_field ; expression;do; start_recordno + 1 ));

 

recordcount_on_expression ( primary_key_field ; expression;do; start_recordno + 1 )

)



;0))

Thanks a lot for the help :)=)

Edited by Guest

That did the trick. The substitute function. Great.... let me be your humble servant

And the quotes around the expression of course(they are a leftover during my tests)

But I am still kinda confused. I do not understand how the substitute function can help here. The return type is still text. So you substitute text with text ?!?!?

No, the return type is NOT text. You substitute the currently held value of the parameter start_recordno for the text "start_recordno".

Expression changes from ???

"GetNthRecord ( rekla_rt_Ersatz::Type ; start_recordno)="Loaner""

to:

"GetNthRecord ( rekla_rt_Ersatz::Type ; 14 )="Loaner""

and THEN gets evaluated.

Edited by Guest

  • Author

Ahhhh

I get it. the variable will be substitute with the actual number and then the substitute function will replace the string with the number.

nice... jee... thanks for the explanation. That kinda thinking will be a good help in the future.

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.