I was recently porting some Fortran code which required some user input
and implemented it using jselect. I have put together something with
jinput & jselect below to illustrate. For Amelia's usage I like Fraser's
suggestion better.

[As an aside it would be nice to improve the jinput class to allow the
name of the input_result function to be customised (like you can for
jselect).]

require 'jinput jselect'
getNums=: 3 : 0
  title=. 'Enter numbers separated by spaces.'
  empty 'jinput' conew~ title;'3 4 56 2';'input_result'
)

input_result=: 3 : 0
  res=: y;(+/ % #)0 ". y  NB. mean
  res=: >":each res
  res 1!:2 (2)

  genders=. ;:'Ewes Rams Wethers'
  title=. 'What gender animals are the data from?'
  empty 'jselect' conew~ genders;title;0;'writeGender'
)

writeGender=: 3 : 0
  if. 0=0{::y do. return. end.
  res=: 2{::y  
  res 1!:2 (2)
) 


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to