I've been fascinated by the simplicity of batch files for quite some time, but now I'm trying to expand their capabilities.
The first thing I've tried is a simple randomizer. It works quite well if I just return the random integer, then use 'if errorlevel' in the batch file, but to make things easier, I wanted to allow the randomizer to directly set a variable in the console.
To do this, I tried
Code:
if (argv[3] != '\0')
{
snprintf(setcmd, sizeof(setcmd), "set %s=%d", argv[3], r);
system(setcmd);
}
which did not work, even though printing setcmd showed it held the right console command.
The weird thing is, other commands such as "echo Foo" and "cls" work, it's just "set var=num" that doesn't.
Any explanation as to why it is so and/or how to go around it would be much appreciated.