Page 1 of 1

About console parameters

Posted: Sat Feb 14, 2004 11:44 pm
by thyr0x1ne
I did a try on PureBasic after a webpages relating articles ... thought libraries quite nice , ressources ... well a powerful langage for hard-coders , and a sweet one for beginners like i am :) thats why for now i prefer keep the free demo.

Btw i was searching for this : can i set parameters in my command line ?
( ex : file.exe -n NAME -r REALNAME )

where -n / -r are flags , and NAME and REALNAME values i could enter with a console application ...

I take a look on RunProgram , and ProgramParameters , but was not able to do sth ... so if you can give me a hand , feel free :) i just hope i will be able to do this without API as my version seems not support them.

Wish you all a nice week end:

thyr0x

Posted: Sat Feb 14, 2004 11:51 pm
by Proteus
I haven't tested it, but this should work.

Code: Select all

Repeat
  Param.s = ProgramParameter()
  Select LCase(Param)
    Case "-n" : NAME.s = ProgramParameter()
    Case "-r" : REALNAME.s = ProgramParameter()
  EndSelect
Until Param = ""

Posted: Sat Feb 14, 2004 11:56 pm
by thyr0x1ne
will try this tomorrow .
many thanks for this quick reply ... just had the time to get a drink :)

Posted: Sun Feb 15, 2004 12:21 am
by thyr0x1ne
seems it dont work ... or most probably i do it bad :
will try tomorrow to parse parameters with spaces and check for the good syntax

Posted: Sun Feb 15, 2004 11:39 am
by Proteus
Parameters with spaces should be surrounded in quotes. Like this:
-n Proteus -r "not putting my real name on the Internet"

It works fine here.

Posted: Tue Feb 17, 2004 11:33 am
by thyr0x1ne
really thanks , it works perfectly