Newsgroups: comp.lang.apl
Path: watmath!watserv2.uwaterloo.ca!torn!utcsri!rpi!gatech!gsusgi1.gsu.edu!gsusgi1.gsu.edu!qmdbms
From: qmdbms@gsusgi2.gsu.edu (Brian Schott)
Subject: a useful (?) example of J
Message-ID: <qmdbms.719175826@gsusgi1.gsu.edu>
Organization: Georgia State University
Date: Thu, 15 Oct 1992 19:03:46 GMT
Lines: 29


I have struggled with the following problem and have finally 
come up with a practical solution.  I am posting this message
in the assumption that others may have a similar need.

Within an explicitly defined function (variable) I would like to
either continue with the next line of the function or exit from
the function, depending on the user's numerical keyboard input.
The function uses 1!:1 to read the keyboard.  Suite ($.) must be 
set to empty in order to exit or it is unchanged if an exit is
not needed (except that by the time suite is accessed it needs
to be beheaded (}.). See the example dummy function below.

     kb =. 1
     read =. 1!:1
     t =. 0 0$''
     t =. t, 'in =. ". read kb'
     t =. t, 'cont =. >'''' ; ": }. $.'
     t =. t, '$. =. ". (0 <: in){cont'
     t =. t, 'y. + in'

     ( t : '') 7
NB. at this point I enter either a positive or negative number at kb.

-- 
Brian Schott/Decision Sciences Dept.             qmdbms@gsusgi2.gsu.edu
College of Business Administration                         404-651-4070
Georgia State University                  interests: approx. reasoning,
Atlanta, Georgia USA 30303-3083     (B=)       decision support systems
