Please enable JavaScript to view this site.

thinBasic Help Manual

Navigation: Introducing ThinBASIC

Example 5 - using console

Scroll Prev Top Next More

* * HELP & MANUAL PREMIUM PACK 4 DEMO VERSION * *

This documentation was styled with a demo skin from the Premium Pack 4 add-on for Help & Manual. The contents of the skin are encrypted and not configurable. You can only publish HM projects with this skin. You cannot edit it or change it.

This version is copyright and may only be used for local testing purposes. It may not be distributed.

Please purchase the full version of the Premium Pack to get the configurable skins and remove this notice. The package will also include the Toolbox configuration utility for Premium Pack skins.

 

Some console usage. Command line parameters reporting.

 

'----------------------------------------------------------------------

 

Uses "console", "os"

 

'---Returns the number of commands specified in command line

Long NumberOfCommands = OS_GetCommands

 

'---Some header

Console_WriteLine("The following are the passed parameters:")

Console_WriteLine(Repeat$(79, "-"))

 

'---Show all parameters

'---See OS_GetCommand function

Long Count

For Count = 0 To NumberOfCommands

Console_WriteLine( Format$(Count, "00") & " " & OS_GetCommand(Count))

Next

 

'---If only 1 param then exit

'---Only 1 parameter means no parameters because parameter 1 is always script name.

If NumberOfCommands <= 1 Then

Console_WriteLine( "Only 1 parameter, program stopped. Press a key to Continue")

Console_WaitKey

Stop

End If

 

'---If more than 1 param, make some tests just for example ...

For Count = 1 To NumberOfCommands

Select Case Ucase$(OS_GetCommand(Count))

  Case "COMPUTERNAME"

    Console_WriteLine(OS_GetCommand(Count) & ": " & OS_GetComputerName)

 

  Case "USERNAME"

    Console_WriteLine(OS_GetCommand(Count) & ": " & OS_GetUserName)

 

  Case Else

    Console_WriteLine("Unknown command: " & SelectExpression)

 

End Select

Next

 

Console_WriteLine("Press a key to continue...")

Console_WaitKey

 

Created with Help+Manual 8 and styled with Premium Pack Version 4 © by EC Software