ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Standard functions / Windows functions / Serial/Parallel Ports functions
  • Miscellaneous
  • Transmission between two computers that use character strings in different formats (UNICODE and ANSI)
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Writes a character string to the output buffer of the specified serial port, parallel port or infrared port. The end of writing can be checked by sInExitQueue.
Remarks:
  • The port must be opened beforehand (sOpen).
Example
// The COM2 port is opened
PortNum = sOpen("COM2", 2000, 2000) // Open COM2
IF PortNum <> 0 THEN
sMessage is string
// Send a message to the output buffer of COM2
sWrite(PortNum, sMessage)
// Wait for the end of the write operation
LOOP
IF sInExitQueue(2) = 0 THEN BREAK
END
Info("End of write operation")
END
Syntax

Writing a buffer into the output buffer of a port Hide the details

<Result> = sWrite(<Port number> , <Buffer to write>)
<Result>: Integer
  • Number of characters written,
  • 0 if timeout is over and if the writing was not performed.
<Port number>: Integer
Identifier of the port used:
  • Port number:
    • Number of the serial port: 1, 2, 3, ... 32 for COM1, COM2, COM3, ... COM32.
    • Number of the parallel port: -1, -2, -3 or -4 for LPT1, LPT2, LPT3 or LPT4.
    • Number of the infrared port: 1, 2, 3, ... 32 for IR1, IR2, IR3, ... IR32.
  • Port identifier returned by sOpen (if this function was called with a port name).
<Buffer to write>: Buffer
Buffer that must be written into the output buffer.
Remarks

Miscellaneous

  • sOpen has no effect if the port was not opened by sWrite.
  • A 32-bit application is locked during the duration of the transfer. To avoid this lock, the timeout between two write operations must be specified in sOpen. When the timeout is over and if the writing was not performed, sWrite returns 0.
  • The time required to transfer the string depends on the transmission speed.
  • The string or the buffer is automatically transferred.
  • WLanguage does not support control signals.
  • The time to wait for a character to be read or written is specified with sOpen.
    • If this time is set to 1s when reading 1024 bytes, the waiting time will be 1024s.
    • If this time is set to "-1s" when reading 1024 bytes, the waiting time will be 1s.
    This prevents lock problems when reading from or writing to the print port.

Transmission between two computers that use character strings in different formats (UNICODE and ANSI)

Some conversions are required to perform a transmission between two computers that use different formats of character strings (Windows (ANSI) and Windows Mobile (UNICODE) for example):
Format of character strings on the current computer
Write operation
(sWrite function)
Read operation
(sRead)
String in ANSI format
String in UNICODE format
ANSI
(PC running Windows for example)
The character string will be in ANSI formatNo conversion is requiredConversion required (UnicodeToAnsi)
UNICODEThe character string will be in UNICODE formatConversion required (AnsiToUnicode)No conversion is required
Business / UI classification: Business Logic
Component: wd290com.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 07/16/2022

Send a report | Local help