Shell cmd w/ multiple args
I'm trying to expand on to a simple LUA script I wrote (my first time working with LUA) to allow multiple arguments to be passed to it. The problem I'm running into is it seems that the way I'm doing it gives one argument regardless of what I type (I ran into a similar problem when first writing it where the argument wouldn't be nil when nothing was passed to it).
Here's my script: Code:
import "Turbine" I know could just add a 2nd command specifically written to accept 2 args, but I really want just 1 command to work for everything |
Hi MuNkEy,
if I recall correctly, than there is only one argument passed to Execute: Code:
Execute = function(sender, cmd, args) Regards |
Just an update in case it helps anyone in the future...
I solved this by adding the split function Code:
function split(pString, pPattern) Code:
function Execute(cmd, args) |
you can also easily implement string.split using string.gmatch:
Code:
string.split=function(str,separator) Code:
args = string.split(args, " "); EDIT: After playing with it a bit, I realized that the simple solution I originally posted doesn't account for "empty" values between separator characters and neither the original nor the simple version accounted for empty values at the end of the string. So, a more complete (but slightly uglier) version is: Code:
string.split=function(str,separator) |
All times are GMT -5. The time now is 07:12 AM. |
vBulletin® - Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
© MMOUI