Unicode Related Compiler Errors; Concatenating String; Using Format; Reading And Writing To Files - AMX NetLinx Studio Instruction Manual

Netlinx design v3.3 or higher
Table of Contents

Advertisement

Unicode Related Compiler Errors

The most common type of compiler errors you will encounter while programming for Unicode are caused by not
wrapping Unicode string literals in _WC, passing a WIDECHAR to a function that take a CHAR array or passing a CHAR
array to a function that takes a WIDECHAR array.

If you forget to wrap a Unicode string in _WC, expect to see the following compiler error:
On the line where the string is defined:
On the line where the constant or variable is used:

If you try to pass a CHAR array to a function that expects a WIDECHAR array, expect to see the following
compiler error (on the line where the function call is made).

If you try to pass a WIDECHAR array to a function that expects a CHAR array, expect to see the following
compiler error:
On the line where the function call is made:
Parameter names might not match those listed above.

Concatenating String

Unicode strings and WIDECHAR array cannot be concatenated using the same syntax that ASCII strings use. In NetLinx,
string expressions are enclosed in double quotes and can only contain 8-bit strings. To concatenate Unicode strings and
WIDECHAR arrays, you must use the WC_CONCAT_STRING function:
wcMyString = WC_CONCAT_STRING(_WC('First name'),_WC(' SurName'))
If you attempt to concatenate Unicode strings or WIDECHAR arrays using NetLinx string expressions, expect data loss.

Using FORMAT

The NetLinx Unicode library does not include a Unicode compatible FORMAT function. In NetLinx, the format function
is used to convert numbers to text.
To use FORMAT with Unicode string, use FORMAT to convert the number to a CHAR array and then use CH_TO_WC and
WC_CONCAT_STRING to combine the result with an existing WIDECHAR array.
The following two syntaxes are functionality equivalent:
fTemperature = 98.652
cMyString = FORMAT('The current temperature is%3.2f',fTemperature)
------------------------------------------------------------------------
fTemperature = 98.652
cTempString = FORMAT('%3.2f',fTemperature)
wcMyString = _WC('The current temperature is ')
wcMyString = WC_CONCAT_STRING(wcMyString,CH_TO_WC(cTempString))

Reading and Writing to Files

The NetLinx Unicode library supports reading and writing of WIDECHAR arrays. The WC_FILE routines operate the
same as the FILE routines with the exception of FILE_OPEN. WC_FILE_OPEN takes an additional parameter; the file
format.
The WC_FILE_OPEN returns a special file handle so it is important to only use the file handle returned by
WC_FILE_OPEN with other WC_FILE functions and the file handle used with WC_FILE functions must have been
obtained by calling WC_FILE_OPEN.
The NetLinx Unicode library supports three different file formats for compatibility with files created on a computer.
Windows Notepad supports the same three file formats so files created in Notepad can be read using the WC_FILE
routines and files created using the WC_FILE routines can be read with Notepad.
NetLinx Studio - Instruction Manual
C10571: Converting type [string] to [WIDECHAR]
C10585: Dimension mismatch: [1] vs. [0] and C10533: Illegal assignment
statement
C10585: Dimension mismatch: [1] vs. [0] and Type mismatch in call for parameter
[WCDATA]
C10585: Dimension mismatch: [1] vs. [0] and Type mismatch in call for parameter
[A]
Programming
101

Advertisement

Table of Contents
loading

Table of Contents