Skip to content

LineLength - DfBaseRichEdit

Returns number of characters in line

Type: Function
Return Data Type: integer

Parameters

Parameter Type Description
iLine integer Number of line (zero-based)

Syntax

Function LineLength integer iLine Returns integer

Call Example

Get LineLength iLine to integerVariable

Description

Returns the number of characters in line number iLine.

If iLine is -1, returns the number of characters in the current line. If text is selected, returns number of characters in the line of the beginning of the selected text.

If iLine is greater than total number of lines in control, function returns -1.

This method has no effect if control is not paged.

Sample

This sample gets the length of the current line in control oRichEdit1 and displays it to the user in a message box.

Procedure DisplayCurrentLineAndCount
    integer iLineLength

    // get the length of the current line
    get LineLength of oRichEdit1 -1 to iLineLength

    send Info_Box (string(iLineLength)) "Length of current line"
End_Procedure // DisplayCurrentLineAndCount

Sample

This sample gets the text and length of the current line in control oRichEdit1 and displays it to the user in a message box. The current line number is determined by calling function LineFromChar with a -1 parameter.

Col 1 Col 2
Note: In this sample, the current line number is determined by calling function LineFromChar with a -1 parameter. LineLength is then called with the current line number. The simpler sample above achieves the same result by passing -1 to LineLength.
Procedure DisplayCurrentLineAndCount
    integer iLineNum iCurrentLineNum iLineLength
    string sLine

    // indicates that we want the current line
    move -1 to iLineNum

    // get the line number of the current line
    get LineFromChar of oRichEdit1 iLineNum to iCurrentLineNum
    // get the text of the current line
    get Line of oRichEdit1 iCurrentLineNum to sLine
    // get the length of the current line
    get LineLength of oRichEdit1 iCurrentLineNum to iLineLength

    send Info_Box sLine ("Length of current line: " + string(iLineLength))
End_Procedure // DisplayCurrentLineAndCount

Return Value

Number of characters in line number iLine.