Business Systems 5

of 17
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Related Documents
  CHAPTER 11: PROGRAMMING AND DEVELOPING  APPLICATIONS USING FOXPRO. 11.1 An Overview of Programming A computer program is a series of instructions given to computer to execute them, in general one after the other. These instructions are commands that cause the computer to perform specific tasks. In Visual FoxPro command file is saved with an extension of .prg. Microsoft Visual FoxPro is a powerful interactive data management tool, but you also can access the full power of Visual FoxPro by creating applications. 11.1.1 Creating Files To create a command file: 1. Click File menu and choose New..From the New dialog box that appears, choose Program radio  button and click on the New file button. 2. A program editor will appear. Alternatively, type and modify command <file name > in the Command Window. 3. Type your program in this editor. 4. After you have invoke the commands, invoke File menu and select Save As..When Visual Foxpro displays the Save As dialog box, type the filename to save the current document. 5. Click save button. 11.1.2 Running the Program from the File. We can execute the program by selecting DO from the Program menu and selecting a program from the Do dialog box. Alternatively, type DO <file name> in the Command Window. Basic Programming Concepts  When you write a program, you can store data and manipulate it with a series of instructions. Data and data storage containers are the basic building blocks in programs, and you use commands, functions, and operators to manipulate data and data storage containers. Storing Data     Visual FoxPro provides numerous storage containers to extend ability to easily manipulate data.    Data types  determine how data is stored and how it can be used. You can multiply two numbers together, but you can't multiply characters. You can print characters in uppercase,  but you can't print numbers in uppercase. Some of the primary data types in Visual FoxPro are listed in the following table. Data Types Type   Examples   Numeric   123 3.1415 – 7   Character   Test String 123 01/01/98   Logical   .T. .F.   Date DateTime   {1998-01-01} {1998-01-01 12:30:00 p}   Data Containers Data containers  allow you to perform the same operations on multiple pieces of data. For example, you add the hours an employee has worked, multiply them To perform these operations for every employee If you store this information in containers, and perform the operations on the containers, you can just replace the old data with new data and run the same program again Main containers for data in Visual FoxPro    Variables Single elements of data stored in your computer's RAM (Random Access Memory).Table    To create a variable, store a value to a named Visual FoxPro element using the STORE command or the =    Records Multiple rows of predetermined fields, each of which can contain a  predefined piece of data. Tables are saved to disk..    To create records, use the INSERT - SQL command or the APPEND command.    Arrays Multiple elements of data stored in RAM.    An array can be created using the DIMENSION or DECLARE  command and assign a value to each element by specifying the element using the array name and the element's position, or subscript.    Variables:    Variables are referred to by their assigned names so that you cab refer to the required variables by name and use it in calculations or for some other application.    For naming a variable, follow the same rules as are used for naming a field.    Variable name must contain only letters, numbers, and underscores, and must begin with a letter.    Although a variable name can begin with the underscore (_) character, it is advisable to avoid it.    Variable play very important role in programming: a)   Collecting and sorting inputs. a)   Preserving data from a table record. a)   Storing the results of calculations for the future use. a)   Storing individual items of information that must be globally available throughout an application. Creating and using Variables: There are mainly four types of variables used in Visual Foxpro. Character Variables: Character variables store strings of characters, which can be letters, numbers of combination of both. Numeric Variables:  Numeric Variables are used to store numeric values such as whole or decimal numbers. Date Variables: Date Variables store date values written in MM/DD/YY format Logical Variables: Logical Variables contain a logical value of True or False or Yes or No. Creating Variables: Variable can be created in two ways: 1)   Using the STORE Command:   The format for STORE command is: STORE<expression> TO <variable_name> For example: STORE 0 TO AMT This assigns a numeric value o the variable AMT. 2)   With the assignment (=) operator: The format is: variable=expression For example: AMT=0 This will assign a numeric value 0 to AMT. For Example User can use any of the following commands to create a variable Name Store ‘Patrick’ to NAME Store “‘Patrick’” to NAME Store {Patrick} to NAME User can perform the same result in the following format also:  NAME=“Patrick”  NAME= ‘Patrick’  NAME= {Patrick} Example Store (11/05/70} to b_day Or B_day=11/05/70 Store .T. to choice Or choice-=.T. Displaying and Manipulating Information with ?/?? Commands:    The ? and ?? Commands are used to ask Visual Foxpro to display particular data on the screen.
Related Search
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks