Returning txt in the right console ...

Just starting out? Need help? Post your questions and find answers here.
thyr0x1ne
User
User
Posts: 18
Joined: Sat Feb 14, 2004 11:38 pm

Returning txt in the right console ...

Post by thyr0x1ne »

Well im now addicted to Purebasic nad had some troubles for my first application ... its a console-based one , and i learnd to use parameters

ex: reg.exe -n NAME -r REALNAME

btw , i would like to add a reg.exe which will give a detailled help in the same console windows on NT/XP , cause when i RunProgram with cmd.exe and text to echo , it opens another console window :/

my intention so is that the reg.exe -h displays the help in the same XP/NT console mode

thks for your help
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

Try this:

Code: Select all

Parameter.s = ProgramParameter()

Procedure DisplayHelp()
    PrintN("This is the help text of the application.")
EndProcedure

Procedure DisplayName()
    Parameter.s = ProgramParameter()
    If Parameter <> ""
        PrintN("The NAME parameter given is: " + Parameter)
    Else
        PrintN("No NAME parameter given. Usage: -n <NAME>")
    EndIf
EndProcedure

Procedure DisplayRealName()
    Parameter.s = ProgramParameter()
    If Parameter <> ""
        PrintN("The REALNAME parameter given is: " + Parameter)
    Else
        PrintN("No REALNAME parameter given. Usage: -r <REALNAME>")
    EndIf
EndProcedure

OpenConsole()

While Parameter <> ""
    Select LCase(Parameter)
        Case "-h"
            DisplayHelp()
            Break
        Case "-n"
            DisplayName()
            Break
        Case "-r"
            DisplayRealName()
            Break
    EndSelect
Wend
End
When compiling, in the compiler options, under executable format choose 'console'. this will make it share a calling console.
--Kale

Image
thyr0x1ne
User
User
Posts: 18
Joined: Sat Feb 14, 2004 11:38 pm

Post by thyr0x1ne »

damn another big help from one of you all :)

works perfectly too ... thks ; btw i changed While ... , for Repeat | Until parameter = "" because of an error it returned
Post Reply