Microsoft KB Archive/118524

{|
 * width="100%"|

-

The information in this article applies to:


 * Microsoft FoxPro for Windows, version 2.6

-

SUMMARY
This information is also available in FoxPro's online Help.

To go directly to this topic, choose the "Tips and Tricks" Help topic. Then do one of the following, depending on which online Help file is in use:


 * FOXHELP.HLP: Choose the "Language Tips" jump text.
 * FOXHELP.DBF: Scroll to the "Language Tips" heading.

NOTE: Additional tips are available in the Microsoft FoxPro for Windows Resource Kit. For more information about the Resource Kit, please see the following article in the Microsoft Knowledge Base: "Q112311 FILE: Fw1003.exe FoxPro for Windows 2.5x Resource Kit"

Moving a Screen Object
Use _CUROBJ to move to a particular screen object. This object can even be itself. You might want to do this in order to change the value of an @...GET object while in that object's VALID clause.

The following example changes the value of x without leaving the @...GET. When you set the value of _CUROBJ, try to avoid hard-coding an actual number there because reordering fields in the Screen Builder can cause unexpected results.   x = some_value _CUROBJ = _CUROBJ RETURN .T. To avoid hard coding a value, use an expression like:   _CUROBJ = OBJNUM(myvar)

RUN Command
The RUN command in FoxPro for Windows has a new /N parameter that allows you to launch a Windows-based application:   RUN /N C:\WORD\WINWORD.EXE README.DOC The Microsoft Windows Control Panel contains many utilities that you can use in your applications. You can also call these utilities using the RUN command:   RUN /N CONTROL COLOR RUN /N CONTROL PRINTERS RUN /N CONTROL DESKTOP

Drives and Directories
Several FoxPro functions can be used to obtain information about drives and directories. Compare the returned values after issuing the command SET DEFAULT TO C:\FOXPROW.

Drive:   SYS(5) = C:   SET('DEFAULT') = C: Directories:   CURDIR = \FOXPROW\ SYS(2003) = \FOXPROW FULL(SET('DEFA')) = C:\FOXPROW\ You can also use the ADIR function to see if a specific directory exists. The following example returns 0 only if the path name does not exist. Remember that the path to a network server may not exist if the network connection is broken.   ADIR(temparr,'C:\FOXPROW\*.*','D')=0

USE Command
You can issue the command USE IN 0 to open a table/.DBF in the first available work area. This command does not select that work area in which it opened the table/.DBF. You must use the SELECT command to do this. You can issue the command USE IN to close a table/.DBF without selecting its work area.

A new SHARED clause for the USE command allows you to open a table/.DBF for shared use without using the SET EXCLUSIVE command. For more information about the USE command, refer to the USE topic.

Cross-Tab Output to Spreadsheets
Run the GENXTAB program to create cross-tabulated output that you can COPY TO or EXPORT to a spreadsheet.

Custom Messages
You can display custom messages in the FoxPro status bar. To do this, SET TALK OFF then use the SET MESSAGE TO  command to specify a message. (You can pass a null string to display nothing.) SET MESSAGE TO without a parameter will restore the status bar to its normal functionality.

Preprocessor Directives
Do not use _WINDOWS, _DOS, _MAC, or _UNIX with preprocessor directives (that is, #IF...#ENDIF). These are designed to be runtime variables. For example the following will NOT work:   #define _DOS .t.   #define _WINDOWS .f.

* For code compiled in MS-DOS, the following would not work:

DO CASE CASE _DOS ? "Running in MS-DOS" CASE _WINDOWS ? "Running in Windows" ENDCASE This code would not work because _DOS would be changed to .T. and _WINDOWS would be changed to .F. so that the code could never work properly again. Instead use the following:   #if "Win" $ VERS #define WINDOWS_CODE .t.  #elif "Mac" $ VERS #define MAC_CODE .t.  #elif "Unix" $ VERS #define UNIX_CODE .t.  #else #define DOS_CODE .t.  #endif

#if WINDOWS_CODE ? "Compiled under WINDOWS" #elif DOS_CODE ? "Compiled under MS-DOS" #endif

Prevent Preprocessor Substitution in Text Strings
#DEFINE prevents preprocessor substitution in text strings. Note that [] can be used to delimit text strings. This means that no substitution will be made in the following:   #DEFINE nosub 1

DECLARE an_array(3)

***This will cause a 'variable NOSUB not found' error because no  ***substitution was made

? afunc[an_array[nosub]]

FUNCTION afunc PARAMETER x  RETURN x

Development Tools
The FOXTOOLS.FLL file, which is located in your FoxPro for Windows root directory, contains a variety of functions that you can use to enhance your applications. Many of these functions provide access to API routines and Microsoft Windows functions. You can view these using the DISPLAY STATUS command (after you SET LIBRARY TO foxtools). Additional query words: FoxWin on-line

Keywords         : kbcode FxprgFoxtools Version          : 2.60 Platform         : WINDOWS Issue type       :
 * }