Input and Output Statements in Foxpro

Input and output in foxpro

          As we already know that data can be entered into tables through the APPEND/BROWSE commands. Data entry for tables can also be done through programs. There arises a need to display and accept information in a formatted way.

          The @…say command is used to place data at a particular screen location and to display data stored in fields or memory variables. The @…get commands is used to retrieve data.

Displaying data

 @…say command: -

Syntax: -
@<Row, columns>SAY<expr>
[Function<exprC1>]
[Picture<expr2>]
[size<exprn],<exprn2>]
[font<exprC3>[,<exprN3]]
[STYLE, exprC4>]

Example:-

            @2, 10 say “hello welcome to FoxPro”

 

Syntax:

Input

@row,column | say <char_exp> get <mem_var>      

Output

@row ,column | say <char_exp> get <mem_var>

 

Clear

@row, column to row, column clear

Clear all

 

Ex

            @5, 5 clear to 20, 20

 

Box Command

                        @row1, column1 to row2, column 2

Picture clause

 PICTURE clause is used to control of display or the information to be accepted.

  @..SAY...GETS PICTURE CODES:

    A       -       Allows only alphabets

                9        -       Allows only digits, signs for numeric data

                N       -       Allows Letters and Digits

                #       -       Allows Only Digits, Blanks and Signs

                X       -       Allows any Character

                L       -       Allows any Logical Data T, t, F, f, Y, y, N, n

                Y       -       Allows Only Y, y, N, n

                !       -       Converts letters into uppercase.

                *       -       Displays asterisk in place of leading zeros.

                ,       -       Display the comma

                .       -       Display the decimal Point.

Function Clause

You can include the function clause, the picture clause or both to control how<expr> is displayed or printed. A function clause affects the entire expression. It contains only the following function code.

Function code & Purpose
B Left – justifies numeric data within the display region.
Example:
Clear
Store 2750 to num
@5,20 say num
@6,20 say num function “B”

C Cr is displayed after a positive number to indicate a credit. Can be used with numeric data only.
Example:-
Clear
Store 15432.00 to amt
@5,20 say amt
@6,20 say amt function “c”

D Uses the current set DATE format.
Example:-
Clear
Store 230801 to num
Store “foxproprograming” to tit
@5,20 say num function “D”
@6,20 say tit function “D”

E Edits date type data as British date
Example:-
Clear
Store 230904 to num
@6,20 say num function “E”

T Trim leading and trailing blanks from<expr>
Example:-
Clear
@5,20 ”fox” to tit
@6,20 say tit function “T”

X DB is displayed after negative numbers to indicate a debit. used only with numberic data.
Example:-
Clear
Store -15432.00 to amt
@5,20 say amt
@6,20 say amt function “X”

Z <expr> is displayed as all blanks if its numeric
value is 0. used only with numeric data.
Example:
Clear
Store o to amt
@5,20 say amt
@6,20 say amt function “z”

( Encloses negative numbers in parentheses. Used only with numeric data.
Example:-
Clear
Store –755 to amt
@5,20 say amt
@6,20 say amt function “(“

! Converts alphabetic characters to upper-case used with character data-only
Example:-
Clear
Store “foxpro programming” to tit
@6,20 say tit function “!”

^ Displays numeric data using scientific notation. Used with numeric data only.
Example:-
Clear
Store 75815 to amt
@6,20 say amt function “^”

$
Displays data in currently format. the currency symbol appears before or after the field value depending on the current setting of set currency. used with numeric data only.
Example:-
Clear
Store 75815 to amt
@6,20 say amt function “$”

Picture expression can include the following characters:-

X Allows any character.

Y Allows logical Y, y, N and n only. Converts y and n to Y and N, respectively.
! Displays the current currency symbol specified by set currency. By default, the symbol is placed immediately before or after the field.
* Asterisks are displayed in front of the numeric value. Use with a dollar sign $ for check protection.
. A decimal point specifies the decimal point position.
, A comma is used to specifies digits to the left of the decimal point.

 

Recommended :

FoxPro e-Book
  1. FoxPro Programming Quick Reference e-Book (New! Revised Edition)