Converts from Win32 binary types into OI numbers
Syntax
OIValue = SRP_Win32_To_OI(Value, Type)
Returns
The equivalent OI value represented by the Win32 datatype.
Parameters
Parameter | Description |
---|---|
Value | The Win32 datatype value. |
Type | The Win32 type |
Remarks
Win32 types (INT, FLOAT, etc.) are stored in binary form and are not usable as-is within standard BASIC+ methods. This method makes it easy to convert them into OI variables for use in BASIC+. Simply pass the Win32 value and its type, and you get a number returned. The following types are available for use in the Type parameter:
Type | Parameter Option |
---|---|
16-Bit Signed Integer | "WORD", "SHORT", or "INT16" |
16-Bit Unsigned Integer | "UWORD", "USHORT", or "UINT16" |
32-Bit Signed Integer | "LONG", "INT", or "INT32" |
32-Bit Unsigned Integer | "ULONG", "UINT", "DWORD", or "UINT32" |
64-Bit Signed Integer | "LONGLONG", or "INT64" |
64-Bit Unsigned Integer | "ULONGLONG", or "UINT64" |
Float | "FLOAT" |
Double | "DOUBLE" |
Example
The best example is when receiving data from a socket, which often pass these kinds of data types. In this example, the length of an incoming string is passed first as a 32-bit integer, so we have to convert into an OI value before passing it into SRP_TcpClient again to pull the string.
// Connect to a local socket, send data, and then close TcpClientHandle = 0 If SRP_TcpClient(TcpClientHandle, "CONNECT", "127.0.0.1", "7777") then // Receive the string length (assuming it will be a 32-bit integer) Length = SRP_TcpClient(TcpClientHandle, "RECEIVE", 4) Length = SRP_Win32_To_OI(Length, "INT32") // Receive the string Data = SRP_TcpClient(TcpClientHandle, "RECEIVE", Length) // Close SRP_TcpClient(TcpClientHandle, "CLOSE") end