
Any commands begin with Set will apply to the whole of your project. So it is only needed once in your main module. (i.e. Put your ‘Set default to…’ at the top of your main module.)
Wait command
Wait command uses to wait for use to press any key. Wait [Message] Timeout [seconds] E.g.
- Wait Wait for user to press any key, then continue
- Wait Timeout 2 Wait for user to press any key for 2 seconds, then auto continue
- Wait “Press any key to go back to Main menu…” Timeout 10
Wait for 10 secs before auto continue, and also display the specific message.
*Timeout is how long it will wait for in seconds. If Timeout is 10, then it will wait for 10 seconds. If you don’t put Time out, it will wait forever until a key is press.
Advance: Get user feedback on what key was pressed
You can also get what key user pressed, with that you can create a choice for user to enter, like Yes or no by using Decision Making statements to check. Wait [Message as string] ( Timeout [Duration in seconds] ) to [Variable as string] E.g.
UserKey = “” Set Variables to store user’s key press
Wait “Press a key” to userkey Use wait command, set UserKey to store key press
? “You press “ + userkey + “ key.” Display message showing user’s key press
Below is the example of when combined Decision making:
UserKey = “” Set Variables to store user’s key press
Use Wait command to ask user to enter Y or N and store key into UserKey:
Wait “Are you sure that you want to Exit? (Y/N)” to UserKey
Do case
case upper(Userkey) = “Y” then If user chooses Y, then do the following
@ 5,5 say “You have chosen Yes”
case upper(UserKey) = “N” then If user chooses N, then do the following
@ 5,5 say “You have chosen No”
endcase
endif
This should give an idea, however, if user enters any other keys, it doesn’t do anything. So we can use loop command to help.
UserKey = “”
While key press is not “Y” or not “N” then:
do while (upper(UserKey) <> "Y") and (upper(UserKey) <> "N")
clear
wait "Are you sure that you want to continue? (Y/N)" timeout 2 to UserKey
do case
case upper(UserKey) = "Y"
@ 5,5 say "You have chosen Yes"
case upper(UserKey) = "N"
@ 5,5 say "You have chosen No"
endcase
enddo
You can extend the above example to include some more advanced features. For example, you can use ‘Set cursor’ command to take the cursor off, making it prettier or even use text function and added some error handling.
Set cursor command
Set cursor [ON / OFF] Most uses when you use WAIT(), GET() functions.
Set date command
Set date [Country’s format] E.g.
- Set date USA MM/DD/YY format (Default)
- Set date British DD/MM/Y Y format
- Set date Italian DD-MM-YY format
Below is the table of other possible date formats available:
| Setting |
Format |
| AMERICAN |
mm/dd/yy |
| ANSI |
yy.mm.dd |
| BRITISH/FRENCH |
dd/mm/yy |
| GERMAN |
dd.mm.yy |
| ITALIAN |
dd-mm-yy |
| JAPAN |
yy/mm/dd |
| TAIWAN |
yy/mm/dd |
| USA |
mm-dd-yy |
| MDY |
mm/dd/yy |
| DMY |
dd/mm/yy |
| YMD |
yy/mm/dd |
| SHORT |
Short date format determined by the Windows Control Panel short date setting. |
| LONG |
Long date format determined by the Windows Control Panel long date setting. |
Set default command
This uses to set the default location path. Set default to [Path as string]. E.g. Set Default to “P:\FoxPro”
So every time you call a module or use the database, you can just type the name of the file.
Set Device/Printer commands
Use with Printing functionalities. See Printing section for more information.
Quit command -Let you quit FoxPro completely!
Quit
All MS FoxPro exits and returns to desktop. Simple as that!
Also note: If you are going to put this into your project, I recommend you to put in at a very last stage when you finalize your program.