Using the Dollar Sign as a Relative Coordinate in FoxPro

Last reviewed: June 27, 1995
Article ID: Q114134
The information in this article applies to:
  • Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, 2.5a, 2.5b, and 2.6
  • Microsoft FoxPro for Windows, versions 2.5, 2.5a, 2.5b, and 2.6
  • Microsoft FoxPro for Macintosh, version 2.5b
  • Microsoft FoxBASE+ for MS-DOS, version 2.1
  • Microsoft FoxBASE+ for Macintosh, version 2.01

SUMMARY

The dollar sign can be used to specify the current position in @ ... SAY/GET statements.

MORE INFORMATION

The dollar sign, when used in @ ... SAY/GET statements, returns the row and column of the active write cursor. This makes it possible to position objects relative to the initial position of the cursor.

In FoxBASE+, the write cursor defaults to line 21, and the column is set to 0. While this technique is static from the dot prompt, it is useful in programs for positioning objects relative to an offset. Issuing the following command will place an x at the dot of the dot prompt on the same line, which scrolls up:

   @ $, $ say 'x'

The next command will place the x at the top-left corner of the FoxBASE screen:

   @ $-21, $ say 'x'

In FoxPro 2.0 and 2.5 for MS-DOS and in FoxPro 2.5 for Windows, the behavior is different, in that the write cursor is placed on the desktop and can be used to position objects relative to the last cursor position. In this example, the text is first positioned at row 1/column 2, and then printed one row down and one column to the right:

   @ 1, 2 say 'x'
   @ $+1, $+1 say 'x'

Of course, as in FoxBASE, this is most useful in a program that requires relative positioning of objects.

Alternatively, the ROW() and COL() functions can be used to return the current cursor position, after which it can be incremented to produce offsets from the original position as follows:

   @ 1, 2 say 'x'
   @ ROW()+1, COL()+1 say 'x'


Additional reference words: FoxMac FoxDos FoxWin 2.00 2.50a 2.50b 2.60 2.10
replicate
loop
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.