Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
 

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: flua commandline arguments, print(arg[all_of_them])?< Next Oldest | Next Newest >
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: April 06 2005,05:09 QUOTE

Using flua -f with arguments, i'm able to grab individual arguments with arg[1], arg[2], etc...but what do you do when you don't know the order in which the arguments were entered?

I tried printing the entire contents of the arg table with print(arg), but instead of a string I get some octal representation of the table itself.

Also tried foreachi(arg,print), which kinda works, but it's still not in a format i can use.  Shouldn't there be a way to print the contents of a table?


--------------
http://www.tldp.org/LDP/intro-linux/html/index.html
Back to top
Profile PM WEB 
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: April 07 2005,02:19 QUOTE

Okay...I think i have something that works.  This doesn't print the whole table as a single string, but it does seem to do what I was originally looking for:
Code Sample

n = 0
function testing()
n = (n+1)
if arg[n] == "-one" then
       print("one: "..arg[n+1])
elseif arg[n] == "-two" then
       print("two: "..arg[n+1])
elseif arg[n] == "-three" then
       print("three: "..arg[n+1])
end
end
foreach(arg,testing)

This tests each argument in sequence.  If it finds "-one" then it will associate that argument with the one immediately following "-one", and do the same for -two and -three.  In this way you can pass arguments to the script in any order, and it will associate the arguments with their approriate functions.


--------------
http://www.tldp.org/LDP/intro-linux/html/index.html
Back to top
Profile PM WEB 
1 replies since April 06 2005,05:09 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

 
reply to topic new topic new poll
Quick Reply: flua commandline arguments

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code