Passing simple arguments to my module/code (in a beautiful way)

Best practices, code snippets for common functionality, examples, and guidelines.
Eike
Posts: 12
Joined: Wed Jul 10, 2019 9:50 am

Passing simple arguments to my module/code (in a beautiful way)

Post by Eike » Sun Mar 29, 2020 1:25 pm

Hello,

I must be missing something obvious. I hope. :)

I got a (code) module (and similar recording modules) that need simple parameterization.
One gets row and column of a table cell to be clicked, the other e.g. the colour of a virtual LED to be checked.
At the moment, I set those arguments in the Data Binding window, defining some Parameter like "one" or "red",
giving it the value of "1" or "red" respectively and pass them to my module.

I hope there's a better way to do that?

Stay safe,
Eike

User avatar
Stub
Posts: 373
Joined: Fri Jul 15, 2016 1:35 pm

Re: Passing simple arguments to my module/code (in a beautiful way)

Post by Stub » Mon Mar 30, 2020 8:24 am

That's how I do it! What were you hoping to do?

Eike
Posts: 12
Joined: Wed Jul 10, 2019 9:50 am

Re: Passing simple arguments to my module/code (in a beautiful way)

Post by Eike » Mon Mar 30, 2020 9:30 am

Basically anything that doesn't force me to call my 1 "one". ;)
It's cluttering up to a long list of useless stuff...

The group parameters do have something I'd prefer, the "constant values" table.

PS: It's like if C++ would force me every time to do

Code: Select all

static int one = 1;
static int two = 2;
int sum = calcSum(one, two);
... instead of calcSum(1,2);

User avatar
Stub
Posts: 373
Joined: Fri Jul 15, 2016 1:35 pm

Re: Passing simple arguments to my module/code (in a beautiful way)

Post by Stub » Mon Mar 30, 2020 11:24 am

Indeed, my Ranorex Data binding parameters list quickly gets full of such constant values, like names of things. I tend to try and nest my folders so I can keep my constant values near where they're used, rather than polluting the broader namespace. I'd also like to be able to share some of these values between Test Suites, rather than duplicating them. Fairly sure that's already a User Voice request.

I have tended to create a pair of code modules where a boolean parameter is required, so I don't have to pass 1/Y/Yes/0/No/N/true/false, etc, into them as parameters. So my code modules mostly tend to take parameters where there is a broader range of values e.g. a colour or a name of something. But when data-driven I have set some code modules to parse boolean parameters.

Not what you're wanting, I know.

Eike
Posts: 12
Joined: Wed Jul 10, 2019 9:50 am

Re: Passing simple arguments to my module/code (in a beautiful way)

Post by Eike » Mon Mar 30, 2020 5:10 pm

Thanks for sharing your experiences and confirming I've not overlooked something obvious to everybody else. ;)

Stay safe!