Menu

expose in ::routine

Help
Igor
2015-09-15
2015-09-24
  • Igor

    Igor - 2015-09-15

    Peace!
    is it possible to use EXPOSE in ::ROUTINE

    PUBLIC='I I1'
    I=1
    I1=3

    call TEST
    exit

    ::routine TEST
    expose PUBLIC
    say I';'I1

    Error 99.907: EXPOSE must be the first instruction executed after a method invo
    cation

    thanks all!

     
  • Igor

    Igor - 2015-09-15

    Thanks Erich! I have knew this way using .local object.

     
  • Per Olov Jonsson

    Hello Igor, here are two more possibilities to solve the problem:

    1: Use the Directory class
    2. Pass the root of a stem. If you give the stem variable the same name everywhere it will be as if it were exposed (in the example I made it different on purpose)

    -- Example 1
    flg = .Directory~new
    flg~One = .false
    flg~Two = '42'

    say 'Before'
    say flg~One
    say flg~Two

    res = Sub(flg)

    say 'After'
    say flg~One
    say flg~Two

    ::routine Sub Public
    trace o

    USE ARG _Flg

    say 'In Routine'
    say _Flg~One
    say _Flg~Two

    _Flg~One = .true
    _Flg~Two = _Flg~Two - 1

    Return .nil

    ::requires 'winsystm.cls'

    -- Example 2

    flg.One = .false
    flg.Two = '42'

    say 'Before'
    say flg.One
    say flg.Two

    res = Sub(flg.)

    say 'After'
    say flg.One
    say flg.Two

    ::routine Sub Public
    trace o

    USE ARG _Flg.

    say 'In Routine'
    say _Flg.One
    say _Flg.Two

    _Flg.One = .true
    _Flg.Two = _Flg.Two - 1

    Return .nil

     
  • Igor

    Igor - 2015-09-24

    Thanks Olov! I knew this way.

     

Log in to post a comment.