Page 1 of 1

Returning txt in the right console ...

Posted: Tue Feb 17, 2004 11:32 am
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

Posted: Tue Feb 17, 2004 3:16 pm
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.

Posted: Tue Feb 17, 2004 5:30 pm
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