palmtree with sun behind it CONTACT US
Phone: (412) 835-9417
Email: sales@vss3.com

Tip #42 Declared Variables

Declared variables make programming with filePro clearer, more flexible and easier than ever.

Defining a declared variable

Long Variable names are an excellent way to manage the many variables you need to process with filePro.  Maximum number of characters in a long variable name is 64.  Avoid using filePro commands as long variable names, names like: select, sort, end, exit, screen, input, will certainly confuse your programming.  The case of the variable does not matter to filePro.  If the variable is MYVARIABLE in one place and MyVariable in another, that is the very same variable.

There are two types of declared variables. 

  • LOCAL  -     A long variable can be LOCAL and will only be available in the processing table where it is defined.   

                        Declare local myvariable(10,allup)

                        Declare myvariable(10,allup)

  • GLOBAL - A global variable may be passed from table to table as you connect processing.  It is defined in the first table and then all other tables just reference that variable by using DECLARE EXTERN

                            Declare global myglobal(10,mdyy/)

  • EXTERN - Indicates the variable is expected to be passed from another table where it is listed as GLOBAL.  The definition of the variable is never supplied in the DECLARED EXTERN form.

                            Declare extern myglobal

Each of these define the variable for use for the current record.  If the variable must be passed from record to record, the ,g option is added to the definition just like when you make a dummy variable.

Declared local myvariable(10,allup,g)

Declared global myglobal(10,mdyy/,g)

Use DECLARED GLOBAL to pass variables from scan processing to output processing, from input processing to CALL or CHAIN tables.  By defining a set of variables to be used to seed a table and a set that represent the output, you can easily develop library tables that can be called to provide function and reduce redundancy.  For example, a table that offers printer selections, or a table that is used to authorize a user.  These can be used from many different tables if they are designed to accept a few variables and output to a set of variables for passing back to the calling table.

Undefined variables

It is possible to use a DECLARED variable with no defined length or edit.  This will load data up to 32,767 into one variable.  (This limit will vary by version so watch it.)  This can also eat up memory, so use this type of variable sparingly or not at all.

                            Declare unknown, bigvariable

  • Use the .g  version of a LOCAL or GLOBAL variable to  make sure the value is passed from level to level to @done.  It is the ,g that keeps the variable between records, not the GLOBAL part.

Sample line:

aa=xx*".06"; tt=xx+aa is made much clearer when the variables reflect the meaning: 

salestax=total*".06";gross_sale=total + salestax   now isn't that more meaningful as a series of commands.

To display or print long variables, the value must be assigned to a field or dummy variable.  It is still only possible to put field numbers or dummy variables on screens or reports.  But you will find there are many more variables used in processing than what you ever need on the actual screen or output.

Now go forth and use the long variables to make your processing more understandable.


Written by Nancy Palmquist

Copyright, 1997 by Virtual Software Systems.  All rights reserved.

Contact Us by: Email to Virtual Software Systems or Phone: (412) 835-9417