Hi,

This is probably not my day for doing PicoLisp. ;-) I cannot get that command line arguments to work, starting with a "-". I want my concatJsonsIntoArray.l to write its result to a file ../test.json. How can I give that file path as an argument to my script? I've tried to get hold of that argument both by using "(argv Fout)" and "(setq Fout (opt))".


I've tried to read this <http://www.software-lab.de/doc/tut.html#script>, but it didn't help me today.

/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

Reply via email to