Negative values in command line parameters.

Hi All,

I want to start my q process with some negative numbers passed in command line.

e.g. q test.q -date 2012.02.02 -feedId -2

But it throws me error treating the “2” as an option.

Has someone encountered the same issue?

Regards.

Anything on the cmd line prefaced with a hyphen is considered an option. Here is some more info - http://code.kx.com/q4m3/13\_Commands\_and\_System\_Variables/#132-command-line-parameters

I guess one option could be to prefix ‘negative’ options with 0 - as either way you are going to have to parse the option to get a non string/meaningful option

By prefixing with 0 you can then ‘value’ the option and avoid a cast

q -q -feedId 0-2

value last .z.x

-2

q -q -feedId 2

value last .z.x

2

q -q -feedId 0+2

value last .z.x

2

I think that’s a bit easier than escaping and casting

q -q -feedId -2

last .z.x

“\-2”

“J”$1_last .z.x

-2

But I’d personally look to changing the feedIds to positive only or maybe incrementing the map or something like that

HTH,

Sean 

single char cmd line params are reserved for kdb+ itself

you can get around that with e.g.

-feedId "-2 "


but better to change your arg so it doesn’t conflict at all

Thanks a lot.. That did help..!

That answers my doubts. Thanks a lot.