Command line parameters?

James Cass cassj at earthlink.net
Thu Mar 11 03:35:44 EST 2004


Kevin -

The environment variable you're looking for is:  $#
For example, if I had this little shell script called "args.sh"

	#!/bin/sh
	echo Number of arguments passed is $#
	for arg in "$@"
	do
   	  echo $arg
	done

and passed it this:
	args.sh 1 2 3 4 5

it would return this:

	Number of arguments passed is 8
	1
	2
	3
	4
	5

Hope this helps....James


On Mar 11, 2004, at 2:14 AM, Kevin wrote:

>
>
> I am unable to locate a construct that would provide the number of 
> parameters that have been passed via the command line.  I am aware of 
> $0 ... $n but how does one know how many there are a how would I loop 
> through them?
>
> Kevin
>
>
> -==-=-=-=-=-=-==-=-=-=-=-=-=-=-==-=-=-=-=-=-
> Disclaimer:
>
> Any resemblance between the above views and those of my
> employer, my terminal, or the view out my window are purely
> coincidental.
> Any resemblance between the above and my own views is 
> non-deterministic.
>
>  The question of the existence of views in the absence of anyone to 
> hold
> them
> is left as an exercise for the reader. The question of the existence of
> the reader
>  is left as an exercise for the second god coefficient.
> (A discussion of non-orthogonal, non-integral polytheism is beyond the
> scope of this article.)
>
>
>
> _______________________________________________
> Join Excite! - http://www.excite.com
> The most personalized portal on the Web!
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>



More information about the use-livecode mailing list