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 CONSOLE
, Set(“Console”), Sys(100)This command determines whether the output from certain commands appears in the active window. The two functions let you find the current setting.
SET CONSOLE ON | OFF
cConsole = SET( "CONSOLE" )
cConsole = SYS(100)
We’ve never really been sure exactly which commands are affected by SET CONSOLE
since we’ve never wanted to turn it off. Some of the affected commands are DISPLAY and LIST
, ? and ??, SUM, AVERAGE and CALCULATE. Interestingly, SETting TALK OFF affects all of those commands except ? and ??. Maybe that’s why we’ve never looked too hard at CONSOLE. The one place we find it really handy is for reports. If we SET CONSOLE
OFF, we don’t have to remember to put REPORT FORM whatever NOCONSOLE in our programs.
The two functions behave slightly differently. SET(“CONSOLE”) reflects the current status wherever you are, while SYS(100) tells you what’s going on in a program. Since SET CONSOLE
OFF is ignored in the Command Window, when you issue SET(“CONSOLE”) from there, you always get back “ON”. In a program, it properly tells you the current setting. When you issue SYS(100) from the Command Window, it tells you how CONSOLE was set the last time you ran a program.
One thing that trips up a lot of people is that errors always turn CONSOLE on. There’s no way to detect the old setting and restore it at the end of your error handler. By the time you get into the error handler, it’s too late. As a standard, we SET CONSOLE
OFF in the global environment-setting routine at the start of our applications, and forget about it after that.
SET CONSOLE OFF