Version: 01.00.20 - last Update: Tuesday, October 13, 2009, 12:05:00
_EdOpenFil | _EdCloseFi | _EdRevert | _EdSelect | _EdIndent | _EdSendKey | _EdDelete | _EdComment
Foxtools Editor Support Functions
_EDINSERT
_EdInsert() Inserts text at current caret position in the editor session passed in <nWHAND> parameter.
VFP Syntax
= _EdIndent(nWHAND, cText, nTextLen)
Parameters
[in] nWHAND
Fox-window handle of the editor session in question. If nWHANDL is no valid editor-session handle, an error “API call caused an exception” (Error 2028) is raised.
[in] cText
The text to be inserted.
[in] nTextLen
Number of characters to be inserted - can be calculated using LEN(m.cText) easily.
Returns
VOID - no evaluable return value, coz always TRUE.
Remarks
Note: The text always will be inserted at the current caret position.
Note: You don’t have to calculate the exact value of the 3rd <nTextLen> parameter at all. If your:
- <nTextLen> is smaller than real length of <cText>, then Left(m.cText, nTextLen) will be inserted
- <nTextLen> is greater than real length of <cText>, then VFP reads over the internal memory boundary like shown below:
Thus, it seems better to supply _EdInsert() with the correct byte-length for the string passed in <cText>.
VFP Example(s)
Opening an editor session, inserting text before line #2:
CLEAR *\\ Open editor session *\\ use file with at least 2 lines of text nWHAND =_EDOPENFIL("TEST.TXT", 1) *\\ get offset to BOL of last line lnLines = _EdGetLNum(m.nWHAND, _EdGetLPos(m.nWHAND, -1))+1 IF m.lnLines > 1 && one-based numbering here *\\ get BOL offset for 2nd line nOffset = _EdGetLPos(m.nWHAND, 1) *\\ set caret to BOL of 2nd line _EdSetPos(m.nWHAND, m.nOffset) *\\ Insert text lcText = "Hello World" + CHR(13) = _EdInsert(m.nWHAND, m.lcText, LEN(m.lcText))
*\\ Insert text with smaller <nTextLen>
= _EdInsert(m.nWHAND, m.lcText, LEN(m.lcText)-6)
ELSE ? "not enough lines in file" ENDIF