Print internals of a predicate function in Kotlin - kotlin

Can anyone help me understand how can i print the internal of this predicate function in kotlin?
I want to print value of abc & def in xyz function as you see in code. In actual code i want to use this value in error message.
Reference code:

Related

How to construct the By.xpath method for customized locators?

I'm trying to use the By method for the setting of variables in my page object class. One of my scenario requires the table to loop with customized value based on user input.
So I had to write customized xpath. But when trying to write to fit into the By method i'm stuck on how to handle the iteration number. For example the below shows my locator:
By test = By.xpath("//thead/tr[1]/th[" + i + "]"));
It shows error for the "i" value in the declaration, even if int i ; is declared.
Please let me know how to handle this.
As the variable i is of type integer, you have to convert it into a string before constructing the effective locator strategy as follows:
By test = By.xpath("//thead/tr[1]/th[" + toString(i) + "]"));

Can you build an expression inside of a custom code function in Report Builder?

I need to provide my RDL files to teammates so that they can make minor customizations for each client. One of the ways I thought I might improve the efficiency is if I could build more complex expressions inside of custom code functions so that they can input some simple arguments and have the function handle the "heavy lifting" of adjusting the expression accordingly.
This is a very simple example, and not one I would take this step for, but I thought it the easiest place to start figuring out if I can make this work. For instance, in a tablix we want a count returned based on a value where the value is customized per client (and isn't a parameter).
=Count(iif(trim(Fields!Category.Value)="OPTIONA",1,nothing))
Is there a way I could build a function so that my teammates would just need to enter the following?
=Code.CustomFunction("OPTIONA")
My understanding is that the custom code in Report Builder can't query datasets, or at least not in the way that an expression within a tablix would be able to. I've built custom functions that work with the results of an expression added as the argument, but I can't seem to wrap my head around if there's a way to construct an expression within a custom function and pass it back to the expression.
For instance:
Public Function CustomFunction(field As String) As String
Dim customExpression As String = "Count(iif(trim(Fields!Category.Value)=" & field & ",1,nothing))"
Return customExpression
End Function
As expected, this just returns a string with the text of the expression, but not an executed expression. Is what I'm trying to achieve possible with Report Builder?
Or, as an alternative approach, can I somehow place variables at the beginning of an expression that are used later so that anyone else working on the expression just needs to worry about the beginning? Essentially create multiple custom functions and call them later on?
=Code.CustomFunction("OPTIONA",Count(iif(trim(Fields!Category.Value)=Code.CustFunc01(),1,nothing)))
Honestly not sure how I would go about building the functions themselves from here.
You can use a function instead of the related field. The function takes the field string as an argument and the filter string for which will increase the counter. Finally it returns the original field value
Private Dim Counter As Integer
Public Function SetCounter( Expr As String, Filter As String) As String
If Expr = Filter Then Counter = Counter + 1
Return Expr
End Function
Public Function GetCounter( ) As Integer
Return Counter
End Function
For the field value you can use the following expression (yellow color)
=Code.SetCounter( Fields!MyString.Value,"OPTION A")
To get the counter value you can either use the following expression calling a function (orange color)
= Code.GetCounter()
Or make the variable public and use Code.Counter as the expression

Why Kotlin doesn't show kotlin.Unit for main function, unlike other functions having Unit return type?

I'm new to Kotlin and while trying the programs when I included functions with Unit return type it showed kotlin.Unit after completion of execution.
Being main function has Unit return type too why it doesn't show kotlin.Unit after execution?
a
b
c
Process finished with exit code 0
This was the output I got for simple program without any other functions
First, please do not upload images of code/errors when asking a question..
But to answer your question: Kotlin is printing the Unit result of calling your function because you're telling it to:
print(compare(a, b))
There's almost never a need to print Unitor manipulate it in any way, but that's perfectly legal to do. And since your main() function also returns Unit, you could print that out too if you wanted (and were calling that from another function). But why would you want to?
Either remove the print(), and simply call compare(a, b) on its own; or change compare() to return a value that you do want to print!

Format - Expected Array

I keep getting an error when I try to format this number. I've done it in VBA before and I tried to change the SOPID to a variant, a string, and an integer.
Dim SOPID As Integer
SOPID = DMax("file_id", "tblSOP") + 1
'Output test data
MsgBox (format(SOPID, "000"))
I have no idea what I am doing wrong.
Assuming the code was pasted directly from your IDE, the casing of format is suspicious; that would be Format, unless there's a format variable or function that's in-scope, ...and that's being invoked here.
Look for a public (could be implicitly Public, or if it's in the same module then it could also be Private) format function procedure that expects an array argument: that's very likely what's being invoked here.
Rubberduck (free, open-source; I manage this project) can help you easily identify exactly what's being invoked and an inspection would tell you about any shadowed declarations, but to be sure you can fully-qualify the function call to avoid inadvertently invoking another function that's in scope:
MsgBox VBA.Strings.Format$(SOPID, "000")
Note that there are no parentheses around the argument list of a parameterized procedure call in VBA; the parentheses you have there are surrounding the first argument and making the expression be evaluated as a value that is then passed to the invoked function: this isn't necessary.
Also note the $: the VBA.Strings.Format function takes and returns a Variant; VBA.Strings.Format$ takes and returns a String. If you aren't dealing with any Null values (an Integer couldn't be Null), consider using the String-returning alias.

Gnuradio number of output items

I'm trying to display "number of items on the output stream" in the flowgraph.
Is there a way to access the function: block__nitems_written(unsigned int which_output) from the flowgraph?
So far I have tried "from gnuradio import gr" and then use gr.block__nitems_written(0) as a value in a variable. The error I get is:
module object has no attribute block__nitems_written.
I think I am not calling the function properly. Any help will be appreciated!
You're confusing things! That's not a property of a flow graph.
Each block has its own number of items that it's written to its output ports.
Hence, it's a method of gr.block, which you can only call with a block instance, i.e. typically as self.nitems_written(0) within a block's work method.