Classes in separate files

  • Radler

    Radler - 2011-07-22

    Bear with me, I am using REXX since 1981 and I am familiar with several Object
    Oriented Languages, but ... I can not get OO REXX to work with classes in
    separate files.:-( This is all on 64-bit Windows 7 with the December 5 Version
    of OO REXX

    I want to write a script a.rex, which uses the class b.rex from its own file.
    Having b.rex in the PATH path does not work, having it in the same directory
    as a.rex and making it the current directory does not work either. I believe I
    do not understand the documentation and I do not find samples demonstrating
    this simple structuring.

    Here is my sample, which delivers following error:


    3 - x = .B~new(13)

    Error 97 running D:\Temp\a.rex line 3: Object method not found

    Error 97.1: Object ".B" does not understand message "NEW"

    /--- Begin of File A.Rex ---/

    x = .B~new(13)

    ::REQUIRES 'B'

    /--- End of File A.Rex -----/

    /--- Begin of File B.Rex ---/

    ::class B

    ::method init


    expose current

    current = Arg(1)

    If Datatype(current, "Numerical") = 0 Then current=1

    /--- End of File B.Rex -----/

    A working example or any hint is highly appreciated!

  • Rick McGuire

    Rick McGuire - 2011-07-22

    Class definitions that are intended to the shared with other files must be
    marked with the PUBLIC keyword, otherwise they are only visible to code within
    the same file. Change your class B declaration to

    ::class B public

  • Radler

    Radler - 2011-07-22

    Oh Boy! That is easy and that makes sense and I even remember that I saw the
    keyword somewhere. Excuse me and thanks a lot for the immediate help!!


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks