Thanks Alex. It was stupid of me not to include that "-". ;-)
/Jon
On 25-10-13 21:29 , Alexander Burger wrote:
Hi Jon,
It works quite well. If I call it like this ...
pil ../concatJsonsIntoArray.l ../test.json +
..
However, if I take away the final "(bye)", then I also get this in
my terminal:
[../test.json:1] !? ({"dummy1": 1} {"dummy2": 2} {"dummy3": 3})
{"dummy1": 1} -- Undefined
?
Why is that, and what should I have done different in my program?
PicoLisp interprets its arguments from left to right, according to the
rule that every argument that starts with a '-' is taken as an s-expr,
and every other argument is 'load'ed as a file.
So in the call above "concatJsonsIntoArray.l" is loaded, and then - if
it is done - "test.json" is loaded. This gives the above error. If (bye)
is called, "test.json" will not be encountered.
I would sugget to use (opt) instead of (argv), because it removes the
next argument from the remaning arguments:
(de isJSON (F)
(= "a" (pack (stem (chop F) "."))) )
(let Fout (opt)
(unless Fout
(prinl "No output file argument given")
(bye) )
(out Fout
(let Sep "["
(for Fin (dir)
(when (isJSON Fin)
(prinl Sep)
(in Fin (echo))
(setq Sep ",") ) ) )
(prinl)
(prinl "]") ) )
♪♫ Alex
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe