From: Timothy J H. <tjh...@br...> - 2006-01-25 06:53:02
|
On Jan 23, 2006, at 10:04 PM, Kyle R. Burton wrote: > I see that the arguments to main in jscheme.REPL are handled in =20 > various ways - as files to be loaded, as scheme expressions, or with =20= > support for a -main proc-name arg1 ..., but is there a way of passing =20= > through command line arguments so that they can be accessed by the =20 > scheme code being executed? You can use the -main commandline argument which expects the next =20 string to be a Scheme procedure P and it then grabs the remaining strings and bundles them into an array =20= of Strings, L. It then calls the Scheme procedure P on L. For example, suppose that testing.scm is the following program (define (testing L) (display (.getClass L)) (newline) (display (map (lambda(x) (list x (.getClass x))) (array->list L))) (newline) ) Then we can invoke jscheme and pass command line args to the testing =20 procedure as follows: % java -cp ~/lib/jscheme.jar jscheme.REPL test.scm -main testing 1 =20= 2 3 class [Ljava.lang.String; ((1 class java.lang.String) (2 class java.lang.String) (3 class =20 java.lang.String)) Is this what you are looking for? Best, ---Tim--- > > I'd like to use JScheme to create some command line utilities.=A0 To = do =20 > so I need access to command line arguments, and stdin, stdout and =20 > stderr (the last three appear to be available as System.in , =20 > System.out and System.err, unless there is some JScheme replacement =20= > for them that I'm not aware of...). > > Thanks, > > Kyle > > -- =20 > = -----------------------------------------------------------------------=20= > ------- > Wisdom and Compassion are inseparable. > =A0=A0=A0=A0=A0=A0=A0=A0-- Christmas Humphreys > kyl...@gm...=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0http://=20 > www.neverlight.com/~mortis > = -----------------------------------------------------------------------=20= > ------- |