Building on bill's "t1.ijs" idea, if we save the following (to the end of the "NB.EG..." line) as file "t2.ijs":
NB.* t2.ijs: test getting input from stdin. 3 : 0 '' 1!:2&2 'hello' a=. 1!:1[3 1!:2&2 ] (a-.CRLF,' '),' yourself.' 2!:55[0 ) NB.EG echo hi | jconsole.exe t2.ijs Then, on the command line, run
echo hi | jconsole.exe t2.ijs
you should see: hello hi yourself. On 1/19/07, bill lam <[EMAIL PROTECTED]> wrote:
Yuva, you may try this, save the following into a script t1.ijs NB. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx foo=: 3 : 0 1!:2&2 'hello' a=. 1!:1[3 1!:2&2 ":a.i.a i.0 0 ) foo'' 2!:55[0 NB. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx then, run as jconsole t1.ijs C:\j504>jconsole t1.ijs hello [ output by J ] abcde [ you enter this line then hit enter ] ^Z [ press cntl-Z ] 97 98 99 100 101 10 [ output by J ] I remember input from keyboard (1!:1[1) is supported by the old dos version of J which might be the environment that you wish. However they were decommitted many years ago. Michael Dykman wrote: > you question is not really a J question, it's more of a general > console question.. > > To 'interactively' use stdin, you could run the console as you are > doing .. I beleive , under windows cntl-Z will end your 'interactive' > input stream (cntl-D everywhere else in the world). > > so you could do > c:\> jconsole > [ a =. i. 10 <<== this is typed > ^Z <<== this is typed > 0 1 2 3 4 5 6 7 8 9 <<== this is output, and jconsole exits > > or > C:\> echo "[ a=. i.10" | jconsole > 0 1 2 3 4 5 6 7 8 9 > > or put your text in a file and > C:\> type "myJprog.ijs" | jconsole > > If this isn't clear, you might want to consult something like: > > > On 1/19/07, Yuvaraj Athur Raghuvir <[EMAIL PROTECTED]> wrote: >> I donot understand how to use stdin in the console mode. >> >> After I start the jconsole and type >> stdin '' >> the shell expects input. >> >> But, I donot know how to inform the J interpreter that the input >> sequence is >> done. When I do a ^C, I get a error message. >> >> Q: How do I close my input string to the stdin verb? Am I missing >> something >> here? >> >> Does anyone have a snippet of code that uses stdin, stdout & stderr? >> >> Thanks, >> Yuva >> >> >> On 1/17/07, Eric Iverson <[EMAIL PROTECTED]> wrote: >> > >> > Windows does support stdin, stdout, stderr the same as in Unix. The >> docs >> > are a bit out of date. >> > >> > ----- Original Message ----- >> > From: "Yuvaraj Athur Raghuvir" <[EMAIL PROTECTED]> >> > To: "Programming forum" <[email protected]> >> > Sent: Wednesday, January 17, 2007 9:24 AM >> > Subject: [Jprogramming] Interpreter in J/Windows? >> > >> > >> > > Hello, >> > > >> > > Has anyone created an interpreter in J? >> > > >> > > I am trying to create a small language based on J. And I want this to >> > > run in >> > > a interpreted environment with a possibility to escape into J native >> > > style. >> > > This design is inspired by the way Stevan Apter has written some >> > > interesting >> > > concatenative languages in K (http://www.nsl.com/). >> > > >> > > Also, I see that stdin, stdout and stderr are available only for UNIX >> > > environment. So, how to write a console application in Windows that >> > > can be >> > > launched using jconsole and reads and writes to console? >> > > >> > > Let me know. >> > > >> > > Thanks, >> > > Yuva >> > > >> ---------------------------------------------------------------------- >> > > For information about J forums see >> http://www.jsoftware.com/forums.htm >> > >> > ---------------------------------------------------------------------- >> > For information about J forums see http://www.jsoftware.com/forums.htm >> > >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm >> > > -- regards, bill ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
-- Devon McCormick ^me^ at acm. org is my preferred e-mail ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
