flua commandline arguments


Forum: Other Help Topics
Topic: flua commandline arguments
started by: mikshaw

Posted by mikshaw on April 06 2005,05:09
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?

Posted by mikshaw on April 07 2005,02:19
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.

Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.