Announcement

Collapse
No announcement yet.

[PB-DOS v3.5] Sharing an array with a procedure present in a unit, without passing it

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [PB-DOS v3.5] Sharing an array with a procedure present in a unit, without passing it

    [PB-DOS v3.5]

    From the manual, on page 151, I summarize: to share variables present in the main body of the program, to share it with the code present in an external unit, it is necessary to insert (in the main body of the program) the keyword "PUBLIC" in front of the name of the variable to be shared in the external unit ... while in the external unit it is necessary to put the keyword "EXTERNAL" in front of the variable name (variable present in the main body of the program).

    My question is: how do you can access and use, from inside a unit, an array present in the main body of the program?

    (I want to create an array, shared with a unit without having to pass it as argument of the call to the procedure contained in the unit)

    Thanks a lot to who can give me some indications <3

    Cheers,
    Marcello

  • #2
    I take you tried ....
    Code:
    PUBLIC  X() AS something
    .. and it did not work?

    (Help file does not help with this!)

    I know you could share the address (and number of elements) as simple LONG/DWORDs and from that use an ABSOLUTE array.. but a REDIM would not be reflected back to the the underlying PB Array which is dimensioned on the main program... but that might be good enough for your requirements? (Especially if you updated a PUBLIC "element count" variable and REDIMed with PRESERVE the underlying array on return from the procedure in the PBU file).


    Michael Mattias
    Tal Systems Inc. (retired)
    Racine WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      I have not used pbdos for ages; however, from your paraphrased description I would guess:

      Code:
      MAIN PROG
      
      PUBLIC SHARED Avarb AS INTEGER
      
      INSERTED MODULE
      
      SUB Something()
      
      EXTERNAL SHARED Avarb AS INTEGER
      Walt Decker

      Comment

      Working...
      X