Hello,

I have tried the following and am quite unable to explain the results:

1) Created a script that has two classes 'cc' (for collection) and 'ci' (for
item)
2) Initialize a global variable COLL in the base locale with the collection
instance I work with
3) For the test I added two items. Addition causes adding two nouns in the
base locale that are assigned to verbs which on execution should print a
statement
4) The items are also added into two simple lists in the collection class -
one for IDs and one for Objects (boxed locale) - both lists synchronized in
order
5) Now, based on a certain id value, I pick the object from the other list,
prepare a command and invoke it.

Issue:
When I fetch the object via a copy (#) or from ({) when the left argument is
a result of another computation, the returned variable does not evaluate to
an object. In the case where I choose the object via from ({) and a hard
coded index, I am able to use the result as an object!!

Any clues?

Environment: J601c / 2006-11-17 / 17:05

Regards,
Yuva

Scripts for reference

>>>>>>>>>>>>>>> c1: script having collection locale/class 'cc' and item
locale/class 'ci' <<<<<<<<<<<<<<<<<<<<<<
require 'coutil'
require 'colib'

coclass 'cc'
init =: 3 : 0
    lastid =: 0
    items =: ''
    ids =: ''
    COLL__ =: coname ''
)

additem =: 3 : 0
    i =. conew 'ci'
    id__i =: lastid =: >: lastid
    items =: items,i
    ids =: ids,id__i
    init__i ''
)

coclass 'ci'
id =: ''

init =: 3 : 0
    ('do',(":id),'__') =: 'do'
)

do =: 3 : 0
    n =. coname ''
    smoutput 'called do from ', (5!:5) <'n'
)



>>>>>>>>>>>>>>> c1t: test script <<<<<<<<<<<<<<<<<<<<<<
require '~user\projects\isa\test\c1.ijs'

test =: 3 : 0
    c =: conew 'cc'
    init__c ''
    additem__c ''
    additem__c ''
    y =. 1
    i0 =: (ids__COLL e. y)#items__COLL
    i1 =: (1 0)#items__COLL
    i2 =: (ids__COLL [EMAIL PROTECTED] y){items__COLL
    i3 =: 0 { items__COLL

    cmd =. ". ('do',":y)
    smoutput 'command is ', cmd

    try.
    smoutput 'try i0'
    cmd0 =. cmd,'__i0 '''''
    ". cmd0
    catch.
    try.
    smoutput 'error with i0'
    smoutput 'try i1'
    cmd0 =. cmd,'__i1 '''''
    ". cmd0
    catch.
    try.
    smoutput 'error with i1'
    smoutput 'try i2'
    cmd0 =. cmd,'__i2 '''''
    ". cmd0
    catch.
    try.
    smoutput 'error with i2'
    smoutput 'try i3'
    cmd0 =. cmd,'__i3 '''''
    ". cmd0
    catch.
    smoutput 'error with i3'
    smoutput 'tried all :(!!'
    end.
    end.
    end.
    end.
)

>>>>>>>>>>>>>>> execution result <<<<<<<<<<<<<<<<<<<<<<
   load 'd:\program files\j\user\projects\isa\test\c1t.ijs'
   test ''
command is do
try i0
error with i0
try i1
error with i1
try i2
error with i2
try i3
called do from <,'3'
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to