Navigation: Introducing thinBasic > Example 5 |
|
Some console usage.
Command line parameters reporting.
'----------------------------------------------------------------------
Uses "Console"
Uses "OS"
Dim NumberOfCommands As Long
Dim Count As Long
'---Returns the number of commands specified in command line
NumberOfCommands = OS_GetCommands
'---Some header
Console_Write("The following are the passed parameters:" & $CRLF)
Console_Write(Repeat$(79, "-") & $CRLF)
'---Show all parameters
'---See OS_GetCommand function
For Count = 0 To NumberOfCommands
Console_Write( Format$(Count, "00") & " " & OS_GetCommand(Count) & $CRLF)
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_Write( "Only 1 parameter, program stopped. Press a key to Continue" & $CRLF)
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_Write(OS_GetCommand(Count) & ": " & OS_GetComputerName & $CRLF)
Case "USERNAME"
Console_Write(OS_GetCommand(Count) & ": " & OS_GetUserName & $CRLF)
End Select
Next
Console_Write( "Press a key to Continue" & $CRLF)
Console_WaitKey
© 2004-2008 thinBasic. All rights reserved. | Version 1.7.0.0 | Web Site: http://www.thinbasic.com |