Announcement

Collapse
No announcement yet.

Passing string expression to function expecting BYREF ASCIIZ parameter

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

  • Kev Peel
    replied
    However, I believe I am in a VERY SMALL minority with this opinion.
    Yes.

    Leave a comment:


  • Michael Mattias
    replied
    For some reason, I thought that would not work. Perhaps it didn't work like that with older versions of the compiler?
    Perhaps there have been some differences across versions.

    In any case I don't think it should work, I think it should return a parameter mismatch error at compile time.

    However, I believe I am in a VERY SMALL minority with this opinion.



    MCM

    Leave a comment:


  • Kev Peel
    replied
    AFAIK, PB has always allocated a temporary fixed buffer when an ASCIIZ parameter is passed "raw data" (string literals, etc). The amount allocated is the length of the data plus one (for the NULL terminator). If an empty string is passed then you get a NULL pointer.

    You can change this buffer but it is discarded once the function is terminated and the stack gets cleaned up.
    Last edited by Kev Peel; 4 Feb 2009, 04:48 PM.

    Leave a comment:


  • Bern Ertl
    replied


    For some reason, I thought that would not work. Perhaps it didn't work like that with older versions of the compiler? In any event, thanks.

    Leave a comment:


  • Chris Holbrook
    replied
    Code:
    #compile exe
    #dim all
    
    sub x ( z as asciz)
        ? z
    end sub
    '-------------------------------
    function pbmain () as long
        local s as string
        
        s = "one, two"
        x(parse$(s,2))
    
    end function

    Leave a comment:


  • Edwin Knoppert
    replied
    >I could assign it to a STRING variable and call the function with BYVAL STRPTR( )..

    This is what i do yes.

    Not sure you can reuse the outcome of a function like Parse()

    Leave a comment:


  • Passing string expression to function expecting BYREF ASCIIZ parameter

    Is there a way to directly pass a string expression to function expecting BYREF ASCIIZ parameter (without first assigning it to an ASCIIZ variable)?

    IOW, I want to pass something like PARSE$( a$, $BS, 1) to a function like FUNCTION ProcessData( szSource AS ASCIIZ) AS LONG. I know I can assign the PARSE$ to an ASCIIZ variable, but then I'm forced to impose a limitation on the size of strings that the database can hold and I'd rather not do that if possible.

    I could assign it to a STRING variable and call the function with BYVAL STRPTR( ), but I'm wondering if there is a way to bypass that assignment and use the expression directly in the function call?
Working...
X
😀
🥰
🤢
😎
😡
👍
👎