I found the following:If you have a program called foo.k, then typingk foo abc d efwill put into the variable _i within the foo program the strings"abc", “d”, and “ef”.How would one do the same sort of thing in “q”?
Hello,
.z.x should do the trick. .Q.opt adds a nice dictionary format to
command line parameters also as shown in the below link.
https://code.kx.com/trac/wiki/Reference/dotzdotx
Regards,
Fintan.
test.q is as follows:.z.xb: .Q.opt .z.xx: value bpot : x[0]pW : x[1]bank : x[2]potpWbankexecuting the code in the following manner:q test.q -pot 123 -Pw 0.232 -bank 2000.00returns:(“-pot”;“123”;“-Pw”;“0.232”;“-bank”;“2000.00”),“123”,“0.232”,"2000.00"Being a newbie…How would you add pot+bank to come up with 2123.00In general, how do you use arguments from the command line to docalculations in a program.On Jun 29, 9:57?pm, butch <elmer_…> wrote:> I found the following:>> If you have a program called foo.k, then typing>> k foo abc d ef>> will put into the variable i within the foo program the strings> “abc”, “d”, and “ef”.>> How would one do the same sort of thing in “q”?</elmer…>
sum"F"$first each(pot;bank)
In general, you want something more like
pot:“F”$first b.pot
pW:“F”$first b.pW
bank:“F”$first b.bank
Then you can say pot+bank normally
Depending on how flexible you need your options processing, you can
use various levels of framework.
This assumes all arguments are atomic, and accepts a string of types
for casting:
q){key[y]set’x$first each y}[“FFF”].Q.opt .z.x;
q)pot
123f
q)pW
0.232
q)bank
2000f