Converts from Win32 binary types into OI numbers


OIValue = SRP_Win32_To_OI(Value, Type)


The equivalent OI value represented by the Win32 datatype.


ValueThe Win32 datatype value.
TypeThe Win32 type


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:

TypeParameter 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"


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", "", "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") 
  • No labels