What is different now from before is in J6 there is an smprompt that can write out a line and then wait on the same line for the input prompt.
waiting on the next line was/is/has never been a problem. Often people expect the problem to be a bit more than it is. Those wanting more advanced prompts usually go for forms etc. 2011/12/31 PackRat <pack...@anet.com> > bill lam wrote: > > I'm puzzled. If prompt works for you, why 1!:1]1 didn't? > > Just to make sure that all info is known, this is NOT from jconsole, > which I never use. Rather, this is in a J session in .ijx and where > code is developed in .ijs. > > I tried the 1!:1]1 two different ways, using a cover verb (test1 and > test2) and using in-line code (test3): > > -------------------------------------- > require 'files strings' > > > test1=: 3 : 0 > d=. input 'enter something: ' > smoutput < d > ) > > test2=: 3 : 0 > d=. input2 'enter something: ' > smoutput < d > ) > > test3=: 3 : 0 > d=. 'enter something: ' 1!:1 ]1 > smoutput < d > ) > > input=: 3 : 0 > y > entry=. 1!:1 ]1 > ) > > input2=: 3 : 0 > y > 1!:1 ]1 > ) > -------------------------------------- > > > It turns out from further testing that J does NOT hang when using this > approach. It only SEEMED that way because J was actually waiting for > input. Somewhere along the line, I thought I'd try pressing the ENTER > key--and, lo and behold, it seemed to break out of the "hang up" and > returned me to the normal session condition of waiting for a command. > Then I thought, "Maybe it was really waiting for input of some kind", > and so I typed some random letters before pressing the ENTER key. Lo > and behold (again!), it was working and was really waiting for input > all the time. > > The reason I originally didn't pursue this any further is that the > Dictionary misled me (is this a bug in the Dictionary?) when page > dx001.htm clearly stated, "read from the keyboard (does not work within > a script)". The behavior I described above fit into the Dictionary's > statement (because the seeming misbehaviors were in a script), and so I > didn't pursue it any further but asked here for alternatives instead. > > So, in answer to your question, bill: yes, it really does work; I just > didn't realize it. Well, almost... > > The reason I didn't realize it is that I thought that (in input and > input2) the literal y would display, and it didn't. By inserting > "smoutput" ahead of the y's, the prompts displayed. With test3, the > first line had to be split in two: the first displaying the prompt > using smoutput, and the second the desired code. Because the prompt > literals didn't display originally, I thought the code wasn't working, > when in fact J was waiting for input. (The reason I thought the > prompts would display in the code at the top of this email is that > single literals usually seem to display in J, and I didn't realize that > the safest approach apparently is to always use "smoutput" or "1!:2]2" > to display them.) > > The lingering problem with this approach is that, in contrast to the > "prompt" verb, the prompt literal and the user input are on separate > lines--not a good thing. Here's the visual difference, using an > underscore to indicate the location of the cursor: > > Your 1!:1]1 approach: The "prompt" verb: > > This is the data prompt: This is the data prompt: _ > _ > > Or is there some documentation somewhere that indicates how your > approach can be made to look like the "prompt" verb approach? > > I hope this extra information helps explain the situation more clearly. > > > Harvey > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > -- Björn Helgason, Verkfræðingur Fornustekkum II 781 Hornafirði, t-póst: gos...@gmail.com gsm: +3546985532 twitter: @flugfiskur http://groups.google.com/group/J-Programming Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans góður kennari getur stigið á tær án þess að glansinn fari af skónum /|_ .-----------------------------------. ,' .\ / | Með léttri lund verður | ,--' _,' | Dagurinn í dag | / / | Enn betri en gærdagurinn | ( -. | `-----------------------------------' | ) | (\_ _/) (`-. '--.) (='.'=) ♖♘♗♕♔♙ `. )----' (")_(") ☃☠ ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm