Menu

#585 Windows: Access to positional command-line arguments (ARGV/ARGC)

open
nobody
None
5
2025-05-12
2025-04-16
No

Hello,

tl;dr: How to call gnuplot through a gnuplot script and have positional parameters available?

On Windows, the extension .gp is associated with gnuplot. I think this is done by the installer. Anyway, when a gnuplot script has the suffix .gp,e.g., plot.gp, I can enter plot.gp on the Windows commandline and gnuplot gets called and executes this script.

Further, I know that positional parameters can be activated by adding the flag "-c" to the command line, e.g.,
gnuplot -c plot.gp data.txt foo.png

However, with the simple file association available in Windows, I cannot add the flag "-c" to the commandline without manually fiddling in the registry, can I? Is there a simple way to activate positional parameters when scripting gnuplot on Windows?

If this is not yet possible, I'd like to suggest to implement a "Windows shebang" feature:
I suggest that command line parameters and flags can be conveyed to gnuplot by adding them to the first line in the script which is marked with "#!", for example:
#! -c
would pass the flag "-c" to gnuplot in order to activate positional parameters.

Alternatively, always activate positional parameters when called by a script.

Does that make sense? Please let me have your comments. Thanks.
Dan

Discussion

  • Daniel Dan K.

    Daniel Dan K. - 2025-04-16

    Another alternative came to my mind: honor command line flags and options when called by a script, e.g.,
    plot.gp -c data.txt foo.png
    Yet I don't even know if that is possible in Windows.

     
  • Daniel Dan K.

    Daniel Dan K. - 2025-05-12

    OK, my suggestion basically boils down to reduce the length of the commandline from
    gnuplot -c plot.gp data.txt foo.png
    to
    plot.gp data.txt foo.png on Windows.

    Reconsidering this suggestion, I now think this is not worth the hassle.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.