QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: hanness on December 13, 2020, 02:05:19 pm

Title: How to read parameters passed to a QB64 program from command line
Post by: hanness on December 13, 2020, 02:05:19 pm
This may be something I once asked a long time ago, but for the life of me I can't recall. Let's say I write a program in QB64 and call it "MyProgram.exe". What do I need to put in that program to read parameters passed to it on the command line line? For example, if I call my program by running "MyProgram.exe option1 option2 option3". In addition, how can my program determine how many parameters are being passed to it?

Thanks!
Title: Re: How to read parameters passed to a QB64 program from command line
Post by: SMcNeill on December 13, 2020, 02:27:40 pm
 https://www.qb64.org/wiki/COMMAND$ (https://www.qb64.org/wiki/COMMAND$)

Code: QB64: [Select]
  1.  count = _COMMANDCOUNT
  2. FOR c = 1 TO count
  3.     PRINT COMMAND$(c) 'or process commands sent
Title: Re: How to read parameters passed to a QB64 program from command line
Post by: hanness on December 13, 2020, 02:37:12 pm
Beautiful! Thanks so much.
Title: Re: How to read parameters passed to a QB64 program from command line
Post by: bplus on December 13, 2020, 06:17:04 pm
You can drag and drop files onto your exe and get their names from COMMAND$.