Announcement

Collapse
No announcement yet.

How to get dynamic string handle address?

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

  • How to get dynamic string handle address?

    What I mean is, I have some OBJ ASM procedures that take BYVAL STRING
    arguments. Some of them could potentially need to call PBU UNIT procedures
    that take BYREF STRING arguments. So, how can I go from a string
    handle to the address of the string handle? The only builtin
    PB/DOS string procedures I know of go the opposite direction.

    Thank you for any assistance.



    ------------------

  • #2
    STRPTR points to the data. VARPTR points to the string.

    ------------------
    Tom Hanlin, PowerBASIC Staff
    Opinions expressed may not be those of my employer or myself

    Comment


    • #3
      >The only builtin PB/DOS string procedures I know of go the opposite direction

      PB/DOS offers a documented set of string management functions you might find useful.

      See: Help/Internal Procedures

      But - I don't think you can get from data address to handle.

      And when you think about it, it makes no sense to do so anyway.

      A procedure which takes a "BYVAL" parameter assumes that procedure does not need to modify that parameter; so the data are, "by definition," sufficient.

      Of course, that procedure could always create a LOCAL copy of the parameter and "do something" with that copy <U>locally</U>, but if the parameter was passed BYVAL it can't be changed anyway.


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

      Comment


      • #4
        Thank you for your replies. Of course, Tom, those would be obvious,
        EXCEPT that its procedures in my OBJ files that need the info, so
        STRPTR and VARPTR are not options.


        ------------------

        Comment


        • #5
          Disregard, no longer need replies. I just recoded my UNIT
          procedures so they use BYVAL STRING instead of BYREF strings.
          So, my OBJ procedures and the UNIT procedures can now freely
          "talk to each other."


          ------------------

          Comment


          • #6
            Oh, I see. If you want to get the string handle when all you have is
            the data pointer... no, you're pretty much out of luck.

            Although... there would seem to be some question as to whether that's
            actually the case. If you're passing a genuine STRING type, the result
            result is always going to be a string handle, not a data pointer. It
            doesn't matter whether you use BYREF or BYVAL. A STRING is a STRING.
            No? There may be a question of whether PB would decide to deallocate
            the string if it detects a "temporary" handle, though. DOS BASICs were
            designed with the idea of being able to call asm, not being called from
            asm.

            ------------------
            Tom Hanlin, PowerBASIC Staff
            Opinions expressed may not be those of my employer or myself

            Comment

            Working...
            X