Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#387 METHOD-class: ROUTINE directive not processed ?

3.2.0
closed
nobody
Classes (182)
5
2012-08-14
2007-08-21
No

If one supplies an array of Rexx statements to create a method at runtime, it seems that at runtime a defined routine directive is not found (error 43.1, routine not found).

What follows is first the code saved for the sake of argument in an external file (could be also retrieved via a database or by other means), named "testa.rex".

Thereafter one Rexx program ("testLoadMethod.rex") is depicted which reads the file's content into an array, creates a method object with it and executes it, yielding the aforementioned 43.1 error.

Finally, another Rexx program ("testLoadMethNewFile.rex") is depicted which uses the "newFile" method to create a method from it and runs it flawlessly.

Program which will be wrapped up as a method:
-------------- testa.rex (begin) -------------
say ".t~counter :" .t~counter
t=.t~new
say "t~class~counter:" t~class~counter

say pp("hi")

::routine pp
parse arg a
return "["a"]"

::class t

::method counter attribute class
::method init class
expose counter
counter=0
::method new class
expose counter
counter=counter+1
forward class (super)
-------------- testa.rex (end) ---------------

The following program will yield the runtime error 43.1 when executing the "testa.rex" code:
-------------- testLoadMethod.rex (begin) -------------
parse arg fn
if fn="" then
fn="testa.rex"

st=.stream~new(fn) -- read file's content into an array
arr=st~arrayin
st~close

m=.method~new("someName", arr)

t=.test~new~~addMethod("aha", m)
t~aha

::class test
::method addMethod
use strict arg name, m
self~setMethod(name, m)
-------------- testLoadMethod.rex (end) ---------------

The following program executes the "testa.rex" code flawlessly:
-------------- testLoadMethod.rex (begin) -------------
parse arg fn
if fn="" then
fn="testa.rex"

m=.method~newfile(fn)

t=.test~new~~addMethod("aha", m)
t~aha

::class test
::method addMethod
use strict arg name, m
self~setMethod(name, m)
-------------- testLoadMethod.rex (end) ---------------

Discussion

  • Rick McGuire
    Rick McGuire
    2007-10-02

    Logged In: YES
    user_id=1125291
    Originator: NO

    The mechanism for installing/instantiating directives within the code source context is the CALL instruction or the ::REQUIRES instruction. Installing the leading method of a piece of code on a class as a method bypasses that installation step, resulting in the directives not found. This is working as designed, so as a bug this is invalid. It might be reasonable to allow a call capability on a method object that would produce the same side effects of creating/installing the classes.

     


Anonymous


Cancel   Add attachments