MilesAhead Posted September 15, 2008 Posted September 15, 2008 Anyone know if there are functions for command line switch parsing? Stuff like myprog.exe --option=whatever or /option=whatever I couldn't find anything in the help other than $CmdLine I know I could roll my own but I thought somebody may have invented this wheel already. Always nice to use debugged code. My Freeware Page
PsaltyDS Posted September 15, 2008 Posted September 15, 2008 Anyone know if there are functions for command line switch parsing?Stuff likemyprog.exe --option=whatever or /option=whateverI couldn't find anything in the help other than $CmdLineI know I could roll my own but I thought somebody may have invented thiswheel already. Always nice to use debugged code. It's been done to death. Try out the forum search function. >_< Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
DCCD Posted September 16, 2008 Posted September 16, 2008 (edited) Maybe, i can help you file.exe -h Msgbox: Hello! file.exe -u Msgbox: Bye! file.exe /h Msgbox: Hello! file.exe /u Msgbox: Bye! #cs ---------------------------------------------------------------------------- written by "DCCD" fredj : Email: info.dccd@gmail.com : Website: www.libyalinux.com #ce ---------------------------------------------------------------------------- If $cmdline[0] > 0 Then Switch $cmdline[1] Case "-h", "/h" MsgBox(0, "using -h", "Hello!") Case "-u", "/u" MsgBox(4096, "using -u", "Bye!") Case Else ConsoleWrite(" - - - Help - - - " & @crlf) ConsoleWrite(" -h : msgbox says Hello!" & @crlf) ConsoleWrite(" -u : msgbox says Bye!" & @crlf) ConsoleWrite(" - - - - - - - - " & @crlf) EndSwitch EndIf Exit Edited September 16, 2008 by DCCD [u][font=Arial Black]M[/font]y Blog, AVSS Parts[/u][font=Arial Black]Else[/font][font=Arial Black]L[/font]ibya Linux Users Group
MilesAhead Posted September 16, 2008 Author Posted September 16, 2008 It's been done to death. Try out the forum search function. Yeah I did try it out. You don't know what to search for untilyou find it though. That's why I ask while I'm still searching.Wasted a lot of time with the word "parse" but got intoGetOpt back door through google somehow.Anyway, I went with the quick and dirtyif start of string is /x= then ... cuz I'm lazy. >_< My Freeware Page
MilesAhead Posted September 16, 2008 Author Posted September 16, 2008 Maybe, i can help you Thanks for the reply. That's a viable alternative. Niceand simple. The little utility I'm doing, I have a lotof params that will likely be crammed in a shortcutTarget line so I think it's good to have them gluedtogether with the /x= thingy. >_<I like both solutions since neither has a lot to go wrong. My Freeware Page
MilesAhead Posted September 16, 2008 Author Posted September 16, 2008 Case "-x", "/x !!! Nope, I did it the sloppy way with a big For loop. The more restrictive the method of assigning the options the better. Less to go wrong. I could have just used _Get_Opt or whatever it is... but then if it broke I'd have to figure it out!! With '/x=' options if something doesn't work, most likely it's a matter of which WinApi makes you double quote stuff with a space and which doesn't. Seems to be no consistent pattern. Trial and error still rules!! Besides, I already pasted a bunch of If blocks in my For loop >_< My Freeware Page
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now