Please enable JavaScript to view this site.

ESL Documentation

Navigation: » No topics above this level «

Q6 How can functions that use the string data type be accessed with ECI?

Scroll Prev Top Next More

Esl has its own format for handling strings, which is not compatible with the method used other languages. Before an Esl string can be passed to a Operating System function, or a third party DLL, it must be converted in a standard 'C' string. The simplest method of performing the conversion is by using a structure containing a single string field, as demonstrated in OSUTIL routine "OS_GetTextWidth". The use of a structure, which has to be statically defined means that a finite length of the string must be declared at compile time. The structure used by "OS_GetTextWidth", "OS_String_STR" is defined as a length 256, which means the maximum length of a string is 255 characters, since a NULL must be included as the string delimiter.

An alternative and more flexible method of converting an Esl string into a Pointer, suitable for passing to a standard DLL function, is by making use of the ESLLIB function "EslQueryStringAddr". To use the function, you must include a function prototype in your Esl source code. Looking at the ESLLIB.H supplied with the Esl Development Tools, you will see the following definition:

DllFunc PSZ EAPI EslQueryStringAddr( HSTRING hString);

This definition shows that the function returns a Pointer to a Null terminated string (i.e. PSZ), this pointer can be stored by Esl as an integer. The argument being passed to the function is defined as an HSTRING, this is the Esl format of string. The prototype required is therefore:

FAQs_ECI_Q6_1

The string pointer created by EslQueryStringAddr must be treated as a read-only definition, i.e. the string the pointer addresses must not be modified. If a called function needs to update the string, then the structure method of conversion must be used.