How to get arguments of lua:@myscript.lua 1,"two",3 ?

Here you can discuss any topic concerning Far macro commands.
Post Reply
galaxy_far_FAR_away
Posts: 23
Joined: Mon 12 Aug, 2013 14:03
Has thanked: 6 times

How to get arguments of lua:@myscript.lua 1,"two",3 ?

Post by galaxy_far_FAR_away »

Hi everybody!

I'm such a noob in LUA/FAR macro system :Yahoo!:

So.

I like to call a LUA script-file "myscript.lua" from commandline (for example), and like to pass some arguments to it.

How I can get values of the passed arguments in "myscript.lua"?

I tried "arg[1]" which is nil and read whole luafar_manual.chm & macroapi_manual.en.chm + I read all the internet but I did not get an answer. Seems Google is not my friend? :cry:

Thanks for your help!
User avatar
John Doe
Бюрократ
Posts: 13801
Joined: Wed 27 Apr, 2005 20:42
Has thanked: 72 times
Been thanked: 425 times
Contact:

Re: How to get arguments of lua:@myscript.lua 1,"two",3 ?

Post by John Doe »

arg is deprecated. Use vararg (...)
E.g.
  1. --myscript.lua
  2.  
  3. far.Show(...)
Shmuel
Posts: 6815
Joined: Thu 23 Mar, 2006 21:36
Location: Israel
Has thanked: 41 times
Been thanked: 526 times

Re: How to get arguments of lua:@myscript.lua 1,"two",3 ?

Post by Shmuel »

You can get the arguments the following way: local a,b,c = ...
If you want them in a table: local arg = {...}
To find out how many arguments there are: local narg = select("#", ...)
galaxy_far_FAR_away
Posts: 23
Joined: Mon 12 Aug, 2013 14:03
Has thanked: 6 times

Re: How to get arguments of lua:@myscript.lua 1,"two",3 ?

Post by galaxy_far_FAR_away »

Thank You both for the light-speed answers!

OK, now I feel like I will do hypercomplex plugins for FAR :)
Post Reply

Return to “Macro Commands Discussions”