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 » Thu 24 Jul, 2014 10:59

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: 11390
Joined: Wed 27 Apr, 2005 20:42
Has thanked: 17 times
Been thanked: 101 times

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

Post by John Doe » Thu 24 Jul, 2014 11:11

arg is deprecated. Use vararg (...)
E.g.
  1. --myscript.lua
  2. far.Show(...)

Shmuel
Posts: 5227
Joined: Thu 23 Mar, 2006 21:36
Location: Israel
Has thanked: 16 times
Been thanked: 151 times

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

Post by Shmuel » Thu 24 Jul, 2014 11:25

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 » Thu 24 Jul, 2014 11:55

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”