Author Topic: How to read parameters passed to a QB64 program from command line  (Read 3470 times)

0 Members and 1 Guest are viewing this topic.

Offline hanness

  • Forum Regular
  • Posts: 210
    • View Profile
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!

Marked as best answer by hanness on December 13, 2020, 06:28:56 pm

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: How to read parameters passed to a QB64 program from command line
« Reply #1 on: December 13, 2020, 02:27:40 pm »
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
« Last Edit: December 13, 2020, 02:29:48 pm by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline hanness

  • Forum Regular
  • Posts: 210
    • View Profile
Re: How to read parameters passed to a QB64 program from command line
« Reply #2 on: December 13, 2020, 02:37:12 pm »
Beautiful! Thanks so much.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: How to read parameters passed to a QB64 program from command line
« Reply #3 on: December 13, 2020, 06:17:04 pm »
You can drag and drop files onto your exe and get their names from COMMAND$.