Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: Morwenn on June 04, 2017, 03:57:22 pm

Title: Unable to use %RANDOM% in Project->Set programs' arguments
Post by: Morwenn on June 04, 2017, 03:57:22 pm
One of my projects has a test suite that uses the testing framework Catch. Catch has a command line option --rng-seed to seed the random number generator, and I want to use it with a random seed. In order to achieve that I tried to run the compiled test suite project as follows (Windows 10):

Code
testsuite.exe --rng-seed %RANDOM%

Seeing that it worked fine, I decided to pass the same parameter directly to my Code::Blocks project through "Project->Set programs' arguments". However, when I give the command-line parameter --rng-seed %RANDOM% to Code::Blocks, the command line parser actually receives the string %RANDOM% instead of the corresponding integer. Is there a way to circumvent this problem and have Code::Blocks evaluate %RANDOM% instead of passing it as a string?
Title: Re: Unable to use %RANDOM% in Project->Set programs' arguments
Post by: oBFusCATed on June 04, 2017, 04:04:27 pm
What is %RANDOM%? Environment variable? Some batch built-in function?
Does it work if you use start in the cmd to execute the command?
Title: Re: Unable to use %RANDOM% in Project->Set programs' arguments
Post by: Morwenn on June 04, 2017, 04:07:20 pm
It's the rough equivalent of Unix $RANDOM: it's an environment variable automatically replaced by a random integer.
It does work if I start the cmd to execute the command.
Title: Re: Unable to use %RANDOM% in Project->Set programs' arguments
Post by: oBFusCATed on June 04, 2017, 04:43:45 pm
Can you try with this one: http://wiki.codeblocks.org/index.php/Variable_expansion#Random_values ?
Title: Re: Unable to use %RANDOM% in Project->Set programs' arguments
Post by: Morwenn on June 04, 2017, 04:47:20 pm
I just tried with the four different variable syntaxes described in the linked page, but none worked.
Title: Re: Unable to use %RANDOM% in Project->Set programs' arguments
Post by: stahta01 on June 04, 2017, 04:53:28 pm
Code
testsuite.exe --rng-seed %RANDOM%

I sometimes have to add CMD /C prefix for some things; I suggect trying it like.

Code
CMD /C testsuite.exe --rng-seed %RANDOM%
Title: Re: Unable to use %RANDOM% in Project->Set programs' arguments
Post by: Morwenn on June 04, 2017, 04:56:58 pm
I sometimes have to add CMD /C prefix for some things; I suggect trying it like.

Code
CMD /C testsuite.exe --rng-seed %RANDOM%

The command line I've shared in my first post works perfectly fine. The problem is when I give the parameters through Code::Blocks "Projects->Set programs' arguments", whose interfacce does not provide a full access to the command-line, so I can't add things prior to the executable name with this interface.
Title: Re: Unable to use %RANDOM% in Project->Set programs' arguments
Post by: oBFusCATed on June 04, 2017, 05:14:18 pm
Then I guess you'll need to open a ticket on the sf.net project page, so this problem is not forgotten.
But I'm surprised that it doesn't work. I think we added variable expansion there.
Title: Re: Unable to use %RANDOM% in Project->Set programs' arguments
Post by: Morwenn on June 05, 2017, 12:06:47 pm
Ok, I'll open a ticket on Sourceforge then.