Unlike other CLI parameter/argument routines this one is able to read
thousands without crashing.
I think the reason why other parameter/argument routines crash is because
they are reading the entire argument string into a single string which
exceeds the allocated string buffer.
This parameter routine is different. It does not store the entire argument
string. It only stores the individual parameters. The entire argument
string is read at 1 byte at time from a pointer provided by the OS.
"cli_args.exe" is able to read thousands of CLI parameters even tho it has
only been compiled with a humble "String Buffer Size" of 2048 bytes.
I conducted the following experiment with "cli_args.exe" and a program
called "f-req.lha" from the aminet:-
I ran "cli_args.exe" from CLI as follows:-
cli_args.exe >ram:test.txt `f-req multiselect`
I then selected all of the 3019 files in my YAM/incoming directory.
The file "ram:test.txt" was 137772 bytes.
As you can see this by far exceeds my "String Buffer Size" of 2048 bytes.
Had I have stored the entire argument string into a single string
"cli_args.exe" would have crashed, but instead it worked like a charm. :)
Within this archive I have provided 3 main different argument routines so
you can select the routine which is most suitable for your particular
program if you choose to use any one of these routines.
If you wish to use these CLI arg routines with a WB program then you should
use an alternative to "WBStartup" such as "wbmessage".
These CLI arg routines were influenced by "Args.bas" from here:-
http://aminet.net/package/dev/basic/Basic_Utils
Feeling bored ? :)
Why not check out this URL ?
http://home.iprimus.com.au/lombi/1/homepage.htm
|