Command Line Variables

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Paul.

Does PureBasic have a way to retrieve variables passed to it via command line??

example: file.exe /var1/var2
Then inside file.exe it is able to extract a=var1, b=var2
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Mr.Skunk.

Here is an example to do it :

;
; Command Line Example
;
; It will give you the commande line plus the path
; from where your pogram was launched.
;
; Compile It to have acces to the command line and have fun with it


InitWindow(0)



cmd.l=GetCommandLine_() ; the API call to retrieve a pointer to the command line


#WindowWidth = 600
#WindowHeight = 345

If OpenWindow(0, 10, 120, #WindowWidth, #WindowHeight,#PB_Window_SystemMenu, "Command line example")

DrawingOutput(WindowId())
Locate (40,40):DrawText(peeks(cmd))
Stopdrawing()

Repeat
EventID.l = WaitWindowEvent()


Until EventID = #PB_EventCloseWindow

EndIf

End


Mr Skunk
Post Reply