For your scripts and programs!
Copy this script and paste it into your program. Let me know if you find any bugs.
Example of usage:
Notes:
The script:
function paramstr_to_flags(str)
local function string_is_flag(str)
return type(str)=="string" and str[1]=="-"
end
local function string_is_ok_arg(str)
return type(str)!="string" or #str>0
end
local result={params={},flags={}}
if(#str==0) return result
local raw=split(str," ")
local i=1
while i<=#raw do
local word=raw[i]
if string_is_flag(word) then
i+=1
local args={}
while i<=#raw and not string_is_flag(raw[i]) do
if(string_is_ok_arg(raw[i]))add(args,raw[i])
i+=1
end
result.flags[sub(word,2)]=args
else
if(string_is_ok_arg(word))add(result.params,word)
i+=1
end
end
return result
end |
Example cart (doesn't really work on BBS since you can't provide a paramstr here):
[Please log in to post a comment]




