However, I believe I am in a VERY SMALL minority with this opinion.
Announcement
Collapse
No announcement yet.
Passing string expression to function expecting BYREF ASCIIZ parameter
Collapse
X
-
For some reason, I thought that would not work. Perhaps it didn't work like that with older versions of the compiler?
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:
-
-
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:
-
-
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:
-
-
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:
-
-
>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?Tags: None
-
Leave a comment: