If you need a ByRef parameter, then you will need to copy the
UDT element to a string variable before calling the function.
Ie.
Temp$ = hCon(1).IPAddr
Packet = DoFilter( Temp$, Packet)
------------------
Bernard Ertl
Announcement
Collapse
No announcement yet.
One more 'Am I stupid'
Collapse
X
-
Thanks
That fixed it.
What if I wanted to modify the variable?
ie. ByRef
------------------
Leave a comment:
-
Ben,
Your function is expecting a ByRef STRING parameter. Ie, a
pointer to a PB string handle.
Your error is trying to pass a UDT element which is actually
passing a pointer to the actual string space and not a string
handle. If you are not modifying the string parameter, make it
a BYVAL parameter and it should work.
IOW,
Code:FUNCTION DoFilter( BYVAL IPAddr AS STRING, Packet AS ASCIIZ) AS STRING FUNCTION = Packet END FUNCTION
------------------
Bernard Ertl
Leave a comment:
-
Here is an actual program file.
It won't do anything but it should compile.
It won't. You have to comment out the first DoFilter Call.
$COMPILE EXE "Test.exe"
TYPE STACK_INFO
IPAddr AS STRING * 15
END TYPE
GLOBAL hCon() AS STACK_INFO
FUNCTION DoFilter(IPAddr AS STRING, Packet AS ASCIIZ) AS STRING
FUNCTION = Packet
END FUNCTION
FUNCTION DoMSH(ID AS LONG, tStack AS STACK_INFO, Packet AS ASCIIZ, StackCount AS LONG) AS LONG
' I get a parameter type mismatch here
Packet = DoFilter(hCon(1).IPAddr, Packet) '<< Rem out and it compiles
' If I change it to the following it works
Packet = DoFilter("10.10.10.10", Packet)
END FUNCTION
' INCLUDES FILES
$INCLUDE "WIN32API.INC" ' Comes with PB/DLL. I have slightly modified it
' Main function required for all windows executables
FUNCTION WINMAIN (BYVAL hInstance AS LONG, _
BYVAL hPrevInstance AS LONG, _
lpCmdLine AS ASCIIZ PTR, _
BYVAL iCmdShow AS LONG) AS LONG
REDIM hCon(10) AS STACK_INFO
FUNCTION = 0
END FUNCTION
------------------
Leave a comment:
-
Ben,
The assignment should work, but if the string is larger than the
ASCIIZ buffer, it will be truncated.
We posted at the same time. Your code appears to use the same
name for the function parameter as the UDT element. You might try
using unique names.
[This message has been edited by Bern Ertl (edited June 14, 2001).]
Leave a comment:
-
Here is what I have.
TYPE STACK_INFO
IPAddr AS STRING * 15
END TYPE
REDIM hCon(100) AS STACK_INFO
FUNCTION DoFilter(IPAddr AS string, Packet AS ASCIIZ) AS STRING
FUNCTION = Packet
END FUNCTION
FUNCTION DoMSH(ID AS LONG, tStack AS STACK_INFO, Packet AS ASCIIZ, StackCount AS LONG) AS LONG
' I get a parameter type mismatch here
' However it turns out it is screaming about the IPAddr
' element of the structure
Packet = DoFilter(hCon(1).IPAddr, Packet)
' If I change it to the following it works
Packet = DoFilter("10.10.10.10", Packet)
END FUNCTION
------------------
Leave a comment:
-
Huh? The program below compiles and works fine. What error are you seeing?
Code:'- compile with pbdll6 #compile exe #dim all Function rt() as String Function = "the result" End Function Function PBMain() Dim z as ASCIIZ * 100 z = rt() MsgBox z End Function
------------------
dickinson.basicguru.com
Leave a comment:
-
One more 'Am I stupid'
You guys are great. Thanks again for the quick response.
Here is one more.
Declare Function X() as String
Dim Y as ASCIIZ * 1000
' This won't work
' The function is returning a string but the var is ASCIIZ
Y = X()
Thanks Again
------------------
Tags: None
Leave a comment: