Search
Thursday, July 24, 2008 ..:: Articles » FoxPro Summary » Basics ::.. Register  Login
 FoxPro Summary: The Basics Minimize
FoxPro Summary

Print or display output on the screen

  • Use ? command  ? [Message as string  E.g. ? “Hello World!”FONT>
  • Use @ command --@ Y,X say [message as string] E.g. @ 2,2 say “Hello World!”
    [Y-Vertical/Line , X-Horizontal/Space]
  • Use List/Display command –This will describe more in Database programming with FoxPro

 

Extended: Rich Text Styles Formatting

You want something fancier, something nicer, something colourful that dull boring menu driven, but you don’t want to use complicated functions. This section will tell you how to make that happen by just using the function you already know above.

          @ Y,X  say [Message as string] font [Font’s name], [font’s size] style [Font’s style]

E.g.

          @ 5,5 say “Hello World!” font “”,30
          Display Hello World! At default font (initial font), at size 30 points

          @ 5,5 say “Hello World!” font “”,30 style “BIU”
          Same as above, but in Bold, Italic and Underline

          @ 5,5 say “Hello World!” font “Arial”,30 style “B-”
          This uses Arial font (which is this document font), with Bold & Strikeout style.

 

Font's Style: You can use these short forms: B is Bold, I is Italic, U is Underline, N is Normal, - is Strikeout. You can combine this together and put as in string as show in above examples.

DO NOT ABUSE IT. It is not necessary to put it into your project. I put this in, because some people interest in it and ask me how to do it. There is no mark scheme for appearance. You may want to do it, if you have extra time in your project. For more information about colour & fonts, see Helpfile.

Extended: Change default Text styles & formatting

You have to display so many texts using so many @ command, and you have to type a long line of making it bold, different font sizes or different fonts. Luckily, There is a command for you that will apply to the whole thing in once! So you don’t have to type it over and over again. To set the font size to everything: _Screen.FontSize = [Font size as number] E.g. _Screen.FontSize = 20 (Type ? “Test” to see the effect) You can also do the same thing to font name: _Screen.FontName = [Name of the font as string] and so do the style: _Screen.FontBold = [Logical as boolean] E.g. _Screen.FontBold = .t. (Set Font to bold), _Screen.FontItalic = [Logical as boolean] and _Screen.FontUnderline = [Logical as boolean]

Advance: Colour Options for Font, Background, etc.

This is exciting section! You will be using ‘Set color to’ command Set color to [Font colour ( ) ] / [BackGround colour (*) ] E.g. Set Color to B/W* (To see the effect, type ? “Hello World!”)

That example changes the font colour to Blue. Nice! The colour is coded with the letter. Obviously, B is Blue and W is White. N is Black, G is Green, R is Red, GR is Yellow. For the font, You can put ‘ ’ sign in to make it brighter (Try B /W*) The interesting part for me is that you can create other colours by mixing up with primary colours. (This is particularly good for people who good at Art). Eg. RB will give you purple colour! You can experiment these by yourself!

For Background colour, you can uses the same colour code, but ‘*’ sign will make it brighter. ( You have to uses W* to get it fully white) If you want to make the effect to the whole of the screen, then Type clear command.  [Remember, you will see the effect after the command being used, so it should placed at the top, same with any command that starts with ‘Set’] More info? See Helpfile!

Color Color code RGB value
White W 255,255,255
Black N 0,0,0
Dark Gray N 64,64,64 (25% gray)
Gray W 192,192,192
Red R 255,0,0
Dark Red R 128,0,0
Yellow GR 255,255,0
Dark Yellow GR 128,128,0
Green G 0,255,0
Dark Green G 0,128,0
Cyan BG 0,255,255
Dark Cyan BG 0,128,128
Blue B 0,0,255
Dark Blue B 0,0,128
Magenta RB 255,0,255
Dark Magenta RB 128,0,128
Blank X N/A

Click here for MSDN Library references about Colors Overview.

NOTE: Using this command will apply to FoxPro, and not only to your program!. If you want to change back, you have to use set command again. This behavior is consistent to all Set commands.

 

Set Variables to store user’s inputs

  • To store numeric/Money type: [Variable’s name] = [Value] E.g. Choice = 0 (Where 0 is initial no.) [Value] can use as Numeric format E.g. Money = 0.00 (Means that store extra 2 decimal places)

  • To store Character type: [Variable’s name] = “” E.g. Name = “” (Where no text is default)
    To be more specific on how many letters you can use [Variable’s name] = space ([no. of letters] E.g. Name = space(15) (Name will store 15 characters)

  • To store date type [Variable’s name] = ctod([Default date]) E.g.
    ReturnDate = ctod(“”)                   This will store date format (blank is default)
    ReturnDate = ctod(“10/05/01”)     This set default date as 10/05/01)
    ReturnDate = ctod(Date())            This set default date as today’s date

Above example must use ‘Set date’ command together to make it works efficiency.

Please note: [Variable’s name] must start with a letter and no space or any special characters. See helpfile for details on naming variables.

 

Get the user inputs

In order to get the user input, You will have to setup the variable for what you want to get first!E.g. If you want to get user’s choice you may want to set variable Choice = 0

  • Use Get command to ask user to enter the input. Get [Variable’s name] Then use read command to read in the user input. E.g.            
    Choice = 0
    @ 5,5 Get Choice
    Read

 

 

 FoxPro Summary: Main

StatementsNext Topic


 Print   

 Helpfulness Survey Minimize
Content on this page is:



Submit Survey  View Results
Help us improve! You can contribute by post it on the forum, send in the feedback or email to foxpro@jutiphan.com. foxpro@jutiphan.com

 Print   

Copyright 2005-2008 by Jutiphan Mongkolsuthree   Terms Of Use  Privacy Statement