Jay Johengen
Altamahaw-Ossipee, Caroline du Nord, États-Unis
Versions des environnements
>Couple questions as to what this procedure is doing. It works, but I'm not sure about the "@strData" in the GETDATA. Is that a variable by reference? So that after GETDATE runs, the value of strData is returned? Also, why the "SPACE(256)" line? Is it to define it as a string, or to define the length, or both? It works with strings much larger than 256, so I'm just curious what the purpose is. Thanks!
>
> PROCEDURE DMSWinsockControlEvents_DataArrival(bytesTotal AS NUMBER) AS VOID ;
> HELPSTRING "Occurs when data has been received from the remote computer"
>
> strData = SPACE(256) && Define string to pass to GetData
>
> THIS.oSock.GETDATA(@strData)
>
> ? strData
>
> ENDPROC
You can be calling a function that requires a certain size for placing the value in it. So you have to allocate the space before the call. This is true for the Win32 API calls -- they expect certain data types and sizes. If the size is too small, you can have a buffer overrun error -- the string is placed in an allocated memory block that is too small and extends beyond the allocated space (over writing anything after the space). So, you have to allocate the memory; SPACE(256) allocates 256 bytes, then the address of the memory block is passed to the method call @strData. This allows the function to place the value into the allocated memory block.
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement