get console arguments WITHOUT - (win)

Discuss any general programming issues here
plouf
Posts: 666
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

get console arguments WITHOUT - (win)

Post by plouf »

how can i get all command argumetns?
following command will return "1 arg para 123"

hollywood.exe blahblah.hws -1=123

but how you get blahblah.hws ?
Christos
User avatar
airsoftsoftwair
Posts: 5834
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: get console arguments WITHOUT - (win)

Post by airsoftsoftwair »

I think you're looking for GetFileArgument().
plouf
Posts: 666
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Re: get console arguments WITHOUT - (win)

Post by plouf »

GetFileArgument return the FIRST argument only and ONLY if the rest of argumetns are NOT with -
i can not get for example

Example.exe blahblah.exe blablah2.exe
Christos
Flinx
Posts: 342
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: get console arguments WITHOUT - (win)

Post by Flinx »

I also have a similar wish on my list, but hadn't asked yet. My idea was to extend GetCommandLine(), so that a table is returned as third return value, containing all positional arguments. To do this, the passed arguments (with leading -) and parameters would have to be masked out, and the rest passed as table. I have done similar things before to get portable code (anyone remember GCompare/GPatch?).
However because of the existing syntax it would not be possible to write the positional arguments at all places, because parameters are optional, for example for the last argument it would not be clear whether the following word should be a parameter or not. But maybe someone can think of a better solution.
User avatar
jPV
Posts: 734
Joined: Sat Mar 26, 2016 10:44 am
Location: RNO
Contact:

Re: get console arguments WITHOUT - (win)

Post by jPV »

plouf wrote: Mon Oct 10, 2022 8:23 pm hollywood.exe blahblah.hws -1=123

but how you get blahblah.hws ?
https://www.hollywood-mal.com/docs/html ... Info_.html
plouf
Posts: 666
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Re: get console arguments WITHOUT - (win)

Post by plouf »

jPV wrote: Thu Oct 13, 2022 6:36 pm
plouf wrote: Mon Oct 10, 2022 8:23 pm hollywood.exe blahblah.hws -1=123

but how you get blahblah.hws ?
https://www.hollywood-mal.com/docs/html ... Info_.html
this one return full execution path of program no arguments at all
Christos
User avatar
jPV
Posts: 734
Joined: Sat Mar 26, 2016 10:44 am
Location: RNO
Contact:

Re: get console arguments WITHOUT - (win)

Post by jPV »

Well, there are two kinds of arguments, the ones passed to the Hollywood interpreter and the ones passed to the script. I don't think there's a way to get them all combined, and would that even be sensible to mix them up. I think Hollywood's philosophy is that scripts don't need to know interpreter's arguments.

When you're coding a program, it usually matters what arguments are passed for the script, and those you can get with GetCommandLine() (custom arguments starting with "-") and GetFileArgument() (a file given for a compiled script, which is given without "-").

blahblah.hws is a file argument passed for the interpreter, and thus isn't considered important for the actual script code. But if you want to get it for some reason, you can use GetProgramInfo() and use the FilePart() if you want to strip the path from it.
plouf
Posts: 666
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Re: get console arguments WITHOUT - (win)

Post by plouf »

my point is if you create an "exe" win32 cmd for example
and you want arguments to this "command.exe" you have limitations

i dont NEED itright now, but found these limitations during experimental.

As Flinx said, an extension to GetFileAtrributes somehow like table = GetFileAttributes(#GET_ALL) or someway anyway
should be implemented in future
Christos
User avatar
jPV
Posts: 734
Joined: Sat Mar 26, 2016 10:44 am
Location: RNO
Contact:

Re: get console arguments WITHOUT - (win)

Post by jPV »

plouf wrote: Thu Oct 13, 2022 10:22 pm my point is if you create an "exe" win32 cmd for example
and you want arguments to this "command.exe" you have limitations

As Flinx said, an extension to GetFileAtrributes somehow like table = GetFileAttributes(#GET_ALL) or someway anyway
should be implemented in future
Documentation of GetCommandLine() tells "Please note that arguments must be prefixed by a dash character (-)", so all "option arguments" must be prefixed by "-", which is a non-standard way on Amiga compatibles, but understandable compromise for multiplatform consistency.

The only exception is the "file argument" which can be given without "-", but it's only meant for giving a file name (a special case where you give a file that your program will process then) for a script/exe, it isn't meant to be used for setting an option or such.

As the rule is that option arguments must contain "-", I don't see any bigger issue here... although being to able to give multiple "file arguments" would be nice (sometimes you might want to handle many files in your program), which might be what you're asking for when I'm starting to understand the question better now :)
Flinx
Posts: 342
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: get console arguments WITHOUT - (win)

Post by Flinx »

jPV wrote: Fri Oct 14, 2022 7:58 am As the rule is that option arguments must contain "-", I don't see any bigger issue here
I would also find it nicer if you could distinguish between the options and the objects to be handled.
One example where I would have liked to do it this way: As reported, I built music players using Raspberry. To make it easy to turn them off, the file system runs read-only. To make it easy to replace the player program and the music, a script copies the program from a pen drive to the working directory at boot time and makes it executable. And to let the user know when the drive is missing and because the messages of a shell output are too tiny on a 5" display, I made a text viewer that displays a text in full screen mode.
And there I would have preferred to treat the options and the text differently, because in the simplest form then only one argument would be needed.
Post Reply