Command Line Arguments Example

Just starting out? Need help? Post your questions and find answers here.
Taishan
New User
New User
Posts: 6
Joined: Wed May 03, 2023 2:20 am

Command Line Arguments Example

Post by Taishan »

Hi gang

New to PB - coming from VB and C++.

How can I pass command line arguments to a PB program compiled as a console, or non-GUI exe, platform independent (I can figure out Mac and Linux) from here:

"C:\Program Files\xyz.exe 4, 5, D:\abc.ini, D:\cba.txt"

The first command line argument is "4", the second is "5".

The PB procedure performs addition (arg 1+ arg 2)

and the last argument is the "new file path" to save the renamed/output of the procedure.

Winner for least lines of code wins! haha

Cheers
Tai
Last edited by Taishan on Thu May 11, 2023 8:16 pm, edited 3 times in total.
jassing
Addict
Addict
Posts: 1885
Joined: Wed Feb 17, 2010 12:00 am

Re: Command Line Arguments Example

Post by jassing »

ProgramParameter()
Quin
Addict
Addict
Posts: 1127
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Re: Command Line Arguments Example

Post by Quin »

CountProgramParameters() to get the count and validate that it's correct, and ProgramParameter(Index) to get the parameter at each index. You can find both these functions under the Process section of the library documentation :)
Taishan
New User
New User
Posts: 6
Joined: Wed May 03, 2023 2:20 am

Re: Command Line Arguments Example

Post by Taishan »

Thanks jassing and Quin. Glad to see programmers with a sense of humor! :D
Post Reply