Converts from OI numbers into Win32 binary types

Syntax

Win32Value = SRP_Win32_To_OI(Value, Type)

Returns

The equivalent Win32 datatype represented by the OI value.

Parameters

ParameterDescription
ValueThe OI value
TypeThe Win32 type

Remarks

Some APIs require developers to pass INTs, FLOATs, and other WIn32 datatypes, which means we can't simply pass an OI number. This method makes it easy to take any OI variable containing a numerical string and convert it into its Win32 equivalent. All you have to do is specify the Win32 datatype you are after. The following types are available for us 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"
Float"FLOAT"
Double"DOUBLE"

Example

The best example is when sending data on a socket, which often pass these kinds of data types. In this example, the length of an string is sent first as a 32-bit integer, so we have to convert into a Win32 value before passing it into SRP_TcpClient.

String = "Hello, World!"
Length = Len(String)

// Connect to a local socket, send data, and then close 
TcpClientHandle = 0 
If SRP_TcpClient(TcpClientHandle, "CONNECT", "127.0.0.1", "7777") then 
   
   // Send the string length as a 32-bit integer
   Win32Length = SRP_OI_To_Win32(Length, "INT32")
   SRP_TcpClient(TcpClientHandle, "SEND", Win32Length) 
   
   // Send the string 
   SRP_TcpClient(TcpClientHandle, "SEND", String) 
   
   // Close 
   SRP_TcpClient(TcpClientHandle, "CLOSE") 
end
  • No labels