To meet your needs, we constantly work to improve Querix products.
This means that Lycia documentation is developing as well.
In case you have found a certain dissonance between the provided information and the actual behavior of Lycia 3 and/or your applications, please, let us know about this via documentation@querix.com so that we can introduce the necessary changes to our documentation.
Thank you for your attention and cooperation.
The LENGTH() function takes a character string argument and returns an integer, which represents the number of bytes in its argument, ignoring any blank spaces after the character string.
The LENGTH( ) function displays a dialog box with a field, into which you can type a string. The string length is then measured and a message window confirms the string and tells you, by returning an integer value, how many characters it contains.
In the example below, the results of the length() function execution will be displayed in the form message string.
MAIN
DEFINE str CHAR(20)
OPEN WINDOW w1 WITH FORM "length_function"
INPUT BY NAME str
ON ACTION ACCEPT
LET str = fgl_dialog_getbuffer()
MESSAGE "length()=", length(str)
END INPUT
CLOSE WINDOW w1
END MAIN
length_function.per
DATABASE FORMONLY
SCREEN
{
Enter a string and press
ACCEPT button:
[f1 ]
}
ATTRIBUTES
f1=FORMONLY.str;
INSTRUCTIONS
SCREEN RECORD s_rec (
FORMONLY.str
)
DELIMITERS "[]"
These are some of the uses that the LENGTH( ) function can be used for:
· You can check whether a user has entered a database name and, if not, set a default name.
· Check whether the user has supplied the name of a file to receive the output from a report and, if not, set a default output.
· Use LENGTH(string) as the MAX( ) value in a FOR loop, and check each character in string for a specific character. For example, you can check for a period ( . ) to determine whether a table name has a prefix.
LENGTH( ) is also useful as a check on user input. In the following example, an IF statement is used to determine whether the user has responded to a displayed message:
IF LENGTH (l_contact.cont_name) = 0 THEN
NEXT FIELD cont_name
ERROR "You must enter a value for this field" ELSE ...
If its argument is a null string, LENGTH( ) returns zero.
LENGTH( ) is one of the 4GL built-in functions that can also be used in SQL statements. It can also be called from a C function.
In a SELECT or UPDATE statement, the argument of LENGTH( ) is the identifier of a character column. In this context, LENGTH( ) returns the number of bytes in the CLIPPED data value (for CHAR and VARCHAR columns) or the full number of bytes (for TEXT and BYTE data types).
The LENGTH( ) function can also take the name of a database column as its argument but only within an SQL statement.