How to Position Cursor at End of Text in Editing Window

Last reviewed: June 27, 1995
Article ID: Q108667
The information in this article applies to:
  • Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, 2.5a, and 2.5b
  • Microsoft FoxPro for Windows, versions 2.5, 2.5a, and 2.5b

By default, when you open an editing window in FoxPro with the MODIFY MEMO or the @ ... EDIT command, the cursor will be placed at the beginning of the text in the open editing window. Normally you have to press the PAGE DOWN key to put the cursor at the end of the text so that you can start adding more text. To avoid this extra keystroke, you can issue the following code, which automatically places the cursor at the end of the text when you open a memo field for editing.

   USE c:\<foxpro main directory>\tutorial\salesman IN 1
   MODIFY MEMO notes RANGE LEN(notes)+1, LEN(notes)+1
   USE    && close database

According to the online help system, the syntax of the RANGE clause for the MODIFY MEMO command is as follows:

   RANGE <expN1>, <expN2>

   RANGE lets you open a memo editing window with a range of
   characters selected. Characters are selected starting at the
   position specified with <expN1> up to (but not including) the
   <expN2> character. If <expN1> is equal to <expN2>, no characters
   are selected, and the cursor is placed at the position specified
   with <expN1>.

Keeping the last statement in mind, the LEN() function is used to evaluate the number of characters, including spaces, in the memo field. The return value of the LEN() function is used in both numeric expressions of the RANGE clause to place the cursor at the end of the text in the memo field.

NOTE: If the memo field is empty, the cursor will be placed at the beginning of the memo editing window.


Additional reference words: FoxDos FoxWin 2.00 2.50 2.50a 2.50b @...edit
insertion
point
KBCategory: kbprg
KBSubcategory: FxprgGeneral


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 27, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.