Logo

Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.

SET CLOCK, Set(“Clock”)

This command controls both the location and visibility of the system clock. It allows you to turn the clock on and off and to position it either on the status bar or anywhere you want on the screen.

Usage

SET CLOCK ON | OFF
SET CLOCK STATUS | TO [ nRow, nCol ]

Parameter

Value

Meaning

ON

 

Turn on display of the system clock at its last location.

OFF

 

Turn off display of the system clock.

STATUS

 

Turn on display of the system clock in the status bar.

nRow, nCol

Numeric

The position on the main FoxPro screen to display the system clock. Turns the clock on.

Omitted

Return the system clock to its default position in the upper right corner. Turns the clock on.

Every version of SET CLOCK except SET CLOCK OFF turns the system clock on, in addition to anything else it does. You can also turn the clock on and off, though not control its location, in the View tab of the Options dialog.

With CLOCK set to STATUS, if you turn off the system status bar, the clock can’t be seen.

The clock honors the current SET HOURS setting, but ignores SET SECONDS.

In the default location, the clock makes some assumptions about the size of the VFP window. It's happiest when the VFP window is maximized, and may not show up at all or may be cut off if the window isn't maximized. Tamar habitually works with all her applications sized to fill the screen vertically, but not horizontally (and shortcuts on the rightmost section of her desktop)—in her default setup, the clock gets cut off.

Example

SET CLOCK ON       && Make clock visible in last location
SET CLOCK STATUS   && Move the clock to the status bar
SET CLOCK OFF      && Turn the clock off
SET CLOCK ON       && Turn the clock on - in the status bar
SET CLOCK TO 0,0   && Move the clock to the upper left corner

* Have some fun with the clock
=rand(-1)
for nTimes=1 to 10
    SET CLOCK TO SROWS()*RAND(),SCOLS()*RAND()
    =INKEY(1)
endfor

Usage

cClockStatus = SET( "CLOCK" )
cClockPosition = SET( "CLOCK", 1 )

Like most of the SET commands, the corresponding function returns the current settings. SET(“CLOCK”) returns “ON”, “OFF” or “STATUS”, while passing a second parameter returns the position of the clock. While the syntax diagram shows a second parameter of 1, in fact, any number or string will do. The position is returned as a comma-separated string. If you haven’t specified a position, the empty string is returned.

Example

SET CLOCK ON
? SET("CLOCK")    && Displays ON
? SET("CLOCK",1)  && Displays the empty string
SET CLOCK TO 0,0
? SET("CLOCK",1)  && Displays 0.000,   0.000

See Also

Set, Set Hours, Set Status Bar