Electric_Soul Posted June 1, 2010 Posted June 1, 2010 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
bruceR Posted June 1, 2010 Posted June 1, 2010 Also change your evaluate statement as follows: Evaluate ( Substitute( expression; "start_recordno"; start_recordno )) ;
bruceR Posted June 1, 2010 Posted June 1, 2010 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 ) )
Electric_Soul Posted June 2, 2010 Author Posted June 2, 2010 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 ?!?!?
Electric_Soul Posted June 2, 2010 Author Posted June 2, 2010 (edited) 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 June 2, 2010 by Guest
bruceR Posted June 2, 2010 Posted June 2, 2010 (edited) 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 June 3, 2010 by Guest
Electric_Soul Posted June 3, 2010 Author Posted June 3, 2010 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.
Recommended Posts
This topic is 5288 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 accountSign in
Already have an account? Sign in here.
Sign In Now