>
> I am trying to use the .Object setMethod() on a stem in order to dump the
> content of the stem in a certain format
>
Hi Madou, you might want to use enhanced() instead of setMethod()
Below should works for all Collections
recs=.stem~enhanced(.methods)
recs[1] = 'aaa'
recs[2] = 'bbb'
say recs~dumpCollection
Erich
On Tue, Jun 17, 2014 at 4:39 PM, Rick McGuire <object.r...@gmail.com> wrote:
> That is not going to work. SetMethod is a private method, which means it
> can only be used from within the context of a method of the object itself.
> It is intended for writing subclasses that wish to provide some level of
> dynamicism, not for anybody to just attach methods to an object.
>
> Rick
>
>
> On Tue, Jun 17, 2014 at 10:27 AM, Mukenx <muk...@gmail.com> wrote:
>
>> I am trying to use the .Object setMethod() on a stem in order to dump the
>> content of the stem in a certain format. Any help is appreciated.
>> This is what I tried:
>>
>> ------------------
>> recs.1 = 'aaa'
>> recs.2 = 'bbb'
>> recs.~setMethod('dump', .methods~dumpCollection)
>> say recs.~dump
>> exit
>>
>> /**
>> * floating method
>> */
>> ::method dumpCollection
>> mb=.MutableBuffer~new;
>> loop i over self~allindexes~sort;
>> if i = 'DUMP' then
>> iterate;
>> mb~append(self~class~id'['i']:'self[i]||.Endofline);
>> end;
>>
>> return mb~string
>> -------------------------
>>
>> and this is what I get:
>> 5 *-* recs.~setMethod('dump', .methods~dumpCollection)
>> Error 97 running C:\Keita\REXX\sandbox\testSetMethod.rex line 5: Object
>> method
>> not found
>> Error 97.1: Object "RECS." does not understand message "SETMETHOD"
>>
>> However, replacing the stem by a .Directory does work fine.
>>
>> Cheers,
>> Madou
>>
>
>
------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
Oorexx-users mailing list
Oorexx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-users