constructfields
TEMPLATE

The constructfields statement creates one or more new fields based on a template.


Parameters

This statement has one parameter:

template – text and tags that specify options for constructing one or more fields (see discussion below).


Description

This statement creates one or more new fields based on a template. For example, this code will add six fields to the current database.

constructfields "Name"+cr()+
    "Address<width:25>"+cr()+
    "City"+cr()+
    "State"+cr()+
    "Zip"+cr()+
    "Donation<money>"

Each line in the template contains the name of a field to be constructed. Optionally, each field can be customized with one or more tags. Each tag begins with < and ends with >. Most tags are followed with a colon and a value, for example <width:25> in the example above.

Remember, you don’t have to customize the fields with tags, you can do so after the fact with the Field Properties Panel. Also, Panorama tries to be smart about constructing fields, so for example it assumes that an Amount field is for money even if you don’t explicitly tell it.

Note: This statement is used by the Construct Multiple Fields dialog.

Inserting vs. Appending Fields

The constructfields statements normally appends fields to the end of the database. However, if the the template includes an <insert> tag, the new fields are inserted in front of the current field. This example inserts three fields in front of the Email field.

field "Email"
constructfields "<insert>"+"Phone"+cr()+"Cell"+cr()+"Fax"

Field Type Tags

There are five tags for setting the field type: <text>, <integer>, <float>, <money> and <date>.

The <text> tag is almost always unneccessary, because Panorama defaults to this type for most field names.

The <integer> tag specifies that this should be a numeric field containing integers (see Numeric Data). This tag can optionally include an output pattern, for example <integer:#°> for a temperature field (see Numeric Patterns). Note: Panorama will automatically construct the following field names as integers: Age, Check, Count, Days, Duration, Hours, Minutes, Months, Num, Number, Population, Qty, Quantity, Quarters, Score, Seconds, Years.

The <float> tag specifies that this should be a numeric field containing real numbers (see Numeric Data). This tag can optionally include an output pattern, for example <float:#.###e#> for a scientific value. Note: Panorama will automatically construct the following field names as floating point numbers: Angle, Average, Bearing, Depth, Deviation, Distance, Height, Latitude, Length, Longitude, Mass, Max, Maximum, Min, Minimum, Rate, TaxRate, Temp, Temperature, Variance, Weight, Width.

The <money> tag specifies that this should be a floating point numeric field formatted as numeric values (preceded by a currency symbol and with two significant digits after the decimal point). Note: Panorama will automatically construct the following field names as money fields: Amount, Balance, Cost, Credit, Debit, Money, Price, Shipping, SubTotal, Tax, Total, Value.

The <date> tag specifies that this should be a date field (see Dates). This tag can optionally include an output pattern, for example <date:Month dd, yyyy> (see Date Patterns). Note: Panorama will automatically construct the following field names as dates: Arrival, Birthday, Date, Departure, Due, Expires, Purchased, Sold.

Field Geometry Tags

There are two tags for adjusting the geometry of the field: <width:characters> and <align:left/center/right>.

The <width:characters> tag specifies the width of the field in the data sheet. This width is specified in characters, not an absolute dimension like points or inches. If you specify a width of 12, there will be approximately enough space to display 12 characters (some characters are wider than others, so this is not exact). The absolute width depends on the font size being used.

If you don’t include a <width> tag, the default width is 10 characters for text fields, 3 characters for integer fields, and 6 characters for date and floating point fields. Panorama also has a list of default widths for about a hundred common fields, for example a City field defaults to 12 characters while a State field defaults to 3 characters. Of course it’s easy to adjust the width later, so in most cases it may not be worth bothering with an explicity width tag.

The <align> tag specifies the alignment of the field. If the field being constructed is numeric (see above), the alignment is automatically set to right, so you rarely need to use this tag.

Data Editing Tags

These tags customize how the field behaves when being edited.

The <caps> tag controls automatic capitalization. The options are all (everything capitalized), word (first letter of each word is capitalized) and sentence (first letter of each sentence is capitalized). Note: Panorama will automatically set the capitilization option for the following common field names, though you can override with an explicit <caps> tag if necessary: Account, Address, Agency, Apartment, City, Company, Country, Department, First, Gender, Item, Last, Middle, Name, Office, Organization, Pay, Payee, PayTo, Position, PostalCode, Prefix, Province, Room, School, Spouse, State, Street, Suffix, Suite, Title, Zip.

The <clairvoyance> tag enables Panorama’s auto-complete Clairvoyance® feature (see Field Properties). There’s no value for this tag, just leave the tag off if you don’t want Clairvoyance enabled. Note: Panorama will automatically enable Clairvoyance for the following common field names: Account, Agency, City, Company, Country, Department, First, Gender, Item, Last, Middle, Name, Office, Organization, Pay, Payee, PayTo, Position, Prefix, School, Spouse, Suffix, Title.

The <tab> tag enables Panorama’s Space Bar Tab feature (see Field Properties), which allows the space bar to be used to tab to the next field. The value should start with 1 (pressing the space bar once is the same as pressing tab) or 2 (pressing the space bar twice is the same as pressing tab). Note: Panorama will automatically enable the Space Bar Tab feature for the following common field names: Account, Address, Age, Agency, Amount, Apartment, Arrival, Balance, Birthday, Check, City, Company, Cost, Count, Country, Credit, Date, Days, Department, Departure, Due, Duration, Email, Expires, First, Gender, Hours, Item, Last, Middle, Minutes, Money, Months, Name, Num, Number, Office, Organization, Pay, Payee, PayTo, Population, Position, Prefix, Price, Province, Purchased, Qty, Quantity, Quarters, Room, School, Score, Seconds, Sold, State, Street, Suffix, Suite, Title, Years, Zip.

The <default:value> tag sets the default value for the field when a new record is created. For example, for a shipping field you might say <default:UPS Ground>.

The <formula:formula> tag sets up a formula that will calculate the value of this field when other fields change, for example <formula:Quantity*Price>. The `<code:code>' tag is used to define a program that will run when the field is modified. To learn more about these features, see [Automatic Field Calculations & Code][].

Repeating Line Item Fields

Use the <lineitem:count> and <endlineitem> tags to define one or more fields that should repeat with a numeric suffix. In this example, the four lines Qty, Item, Price and Amount will actually generate 24 fields – Qty1, Item1, Price1, Amount1, Qty2, Item2, Price2, Amount2, etc.

Num<integer>
Date
Name
Company
City
State
Zip
Country
Phone
Email
Memo
<lineitems:6>
Qty
Item
Price
Amount<formula:QtyΩ*PriceΩ>
<endlineitems>
SubTotal<formula:sum({AmountΩ})>
TaxRate<default:10>
Tax<formula:TaxRate*SubTotal/100>
Shipping<default:5.00>
Total<formula:SubTotal+Tax+Shipping>

See Line Item Fields for more information on this feature.

Comments

If a line begins with // it will be ignored by Panorama, and you can use it for notes to yourself.


See Also


History

VersionStatusNotes
10.0NewNew in this version.