|
Post by bitvast on Feb 17, 2014 19:48:50 GMT 1
Hi Peter,
Just noticed this new command in the CHANGES log. Is this a replacement for ARGUMENT$ or does it serve a different purpose?
|
|
|
Post by Pjot on Feb 17, 2014 21:28:16 GMT 1
Hey bitvast, Well, yes and no BaCon always strives to be backward compatible. So the existing functionality remains. However, it was already notified in some past threads that passing an argument enclosed in double quotes did not work very well. Furthermore a lot of code was needed in the BaCon program to actually parse command line arguments. The CMDLINE function is meant to simplify the processes of obtaining command line arguments. This is an example program: REPEAT
option = CMDLINE("nf:")
PRINT option PRINT ARGUMENT$
UNTIL option = -1
Here, we specify a possible option to our program called "-n". Next to that we can provide an option "-f" but this needs an additional argument (indicated by the ':'), for example a filename. This name will then appear in the ARGUMENT$ variable. If there is an unknown option, the ASCII value for a question mark is returned (63). If the options are done, then a '-1' is returned - an eventual remaining term on the command line will be returned in ARGUMENT$. So in first instance, ARGUMENTS$ behaves as usual. But as soon the program encounters the CMDLINE function, then ARGUMENT$ is being used for the CMDLINE function. Hope this clarifies it! Peter
|
|
|
Post by bitvast on Feb 17, 2014 23:12:43 GMT 1
Thanks Peter for the explanation. Looks like a very useful addition to BaCon.
|
|