[Jprogramming] Beg Q--what am I doing wrong in this select/case?

Hahn, Harvey hhahn at ahml.info
Sat Feb 23 07:54:10 HKT 2008


As I've mentioned previously, I've been trying to develop a stand-alone app type of script, calling the J server (see my previous messages for details).

Here is a function (incorporating a control structure, as I asked about most recently) that doesn't work correctly:

-----------------------------------------
DoFileRead =: 3 : 0
  select. y
    wdinfo 'val y:'; y
    case. 1;2;3 do.
      wdinfo 'case 1,2,3'; 'read iii1'
      NB. list1 =: iiiread iii1
    case. 4;5;6 do.
      wdinfo 'case 4,5,6'; 'read iii1 and iii2'
      NB. list1 =: iiiread iii1
      NB. list2 =: iiiread iii2
    case. do.   NB. case else:
      wdinfo 'no case match'; ''
  end.
)
-----------------------------------------

I've remarked out the actual lines of code and substituted wdinfo statements instead.  The wdinfo line following the "select" correctly displays the argument to the function.  However, the function keeps going to the "else" case option ("no case match").  Here is the call in the main portion of the script:

DoFileRead arg1

where arg1 is derived from  args =: 3}.ARGV_z_  via an  arg1 =: 0{(>args)  statement.

The actual arguments string (as invoked by a Windows shortcut) looks like this:

"C:\Program Files\j\j.exe" -jijx ReviewFileHandler.ijs 6 c:\iii1.txt c:\iii2.txt c:\iii3.txt

I have tried both  4;5;6  and  '4';'5';'6'  for the case values, for example, but neither version works.  I have also tried playing around (unsuccessfully) with the argument passed to the  DoFileRead  function, but to no avail.

I'm again sure that this must be something really easy and obvious, but I'm completely missing it.  Help, please--and thanks in advance!

Harvey
 
--
===========================================
Harvey E. Hahn, Manager, Technical Services Department
Arlington Heights (Illinois) Memorial Library
847/506-2644 - FX: 847/506-2650 - Email: hhahn(at)ahml(dot)info
OML & Scripts web pages: http://www.ahml.info/oml/
Personal web pages: http://users.anet.com/~packrat



More information about the Programming mailing list