Related Information Examples & Tutorials

How To Format Variables When Assigning

Working with variables provides much flexibility in Collect!'s Report Writer. This topic discusses formatting during variable assignment.

You can assign a field to a variable or you can assign one variable to another. You can apply formatting to the field or variable during the assignment. All operators for formatting text and numeric fields may be used. The value is stored as formatted text string in a String variable.

tip.gif The examples in this topic are enabled in Collect! Version 11.4 Build 3.4 and newer.

Assigning Text And Numeric Fields To A Variable

All operators for formatting text and numeric fields may be applied to a printable field when you assign it to a variable. The field is converted to a formatted text string which is then stored in the String variable.

@varStr* = @de.na<fn>

@varStr holds the Debtor's first name.

@varStr* = @de.pr<!15>

@varStr holds the whole dollar value of the Debtor's Principal
padded to 15 spaces.

Top of page.

Assigning A Check Digit To A Variable

You can assign a check digit formatted printable information field to a variable. This is especially useful for printing barcodes.

@varStr* = @de.fi<cdns>

@varStr holds check digit specified by the <cdns> command.

Top of page.

Assigning A Masked Field To A Variable

Mask formatting can be used when assigning a printable field to a variable.

@varStr* = @de.ss<M0,7,*>

@varStr holds the Debtor's SSN masked with asterisks.

Top of page.

Assigning A Date Field To A Variable

When assigning a Date field to a variable, formatting operators for extracting the Month, Day and Year can be used.

@varYear* = @de.li<yyyy>

@varYear holds the year value of the Debtor's Listed Date.

Top of page.

Assigning A Formatted Variable To A Variable

You can also assign formatting to a variable when you assign it to another variable.

When assigning a variable to another variable, all standard formatting is recognized when applied to the variable. All operators for formatting text and numeric variables may be applied to the variable in the assignment to another variable. The variable is converted to a formatted text string which is then stored in the String variable.

@varStr1 = @de.na<fn>
@varStr2* = @varStr1<20>

@varStr1 = @(de.pr+de.fe)
@varStr2* = @varStr1r<!15>

You can assign a check digit formatted variable to another variable. This is especially useful for printing barcodes.

@varStr1 = @(de.fi+de.u1)
@varStr2* = @varStr1<cdns>

Please refer to Help topics, How To Generate A Check Digit and How to Print Barcodes for details.

Mask formatting can be used when assigning a variable to another variable.

@varStr1 = @(dd.ac)
@varStr2* = @varStr1<M0,7,*>

Top of page.

Date With No Separators

When working with Dates, you can simplify the creation of special formats by assigning variables to another variable.

@varStr1* = @de.li<yyyy> Listed Year
@varStr2* = @de.li<MM> Listed Month
@varStr3* = @de.li<dd> Listed Day
@varStr4* = @(varStr1+varStr2+varStr3)

@varStr4 will display the Date with no separators. If the
Debtor's Listed Date is 09/30/2011 then @varStr4 now holds 20110930.

tip.gif Formatting variables is very useful when you need to print out data in a special format, for instance, electronic processing, where the information must be in a special format. You can use variable assignments to format the data and pad it if needed.

Top of page.

Assign And Pad With Spaces

Variable assignment may be used to format special reports for electronic data submission in any kind of designated fixed format.

tip.gif This is a simplified example to show you the basics of assignment with formatting.

For instance, you may want to assign only the Debtor's first name in a particular position. The command for this is @de.na<fn>. You can assign this to a variable in the following way.

@varName* = @de.na<fn>

Now @varName holds the Debtor's First Name.

Perhaps you are using this in a special report that must be follow a fixed length specification. with 20 spaces in the report allocated to First Name.

You can assign your @varName variable to another variable and apply formatting in the following way.

@varPadName* = @varStr<20>

When you use @varPadName in your report, it will allocate 20 spaces for First Name, truncating or padded as needed so that the fixed length output is preserved.

Top of page.

Assign And Pad With Zeroes

Using variables may become more significant when you are working with numbers. You may need to perform calculations before displaying the result.

tip.gif This is a simplified example to show you the basics of assignment with formatting.

For example, perhaps you need to add the Debtor's Principal and Fees. Then command for this is @(de.pr+de.fe).

You can assign this to a variable in the following way:

@varAmt* = @(de.pr+de.fe)

Now @Amt holds the Debtor's total Principal and Fees. If the the total is $1234.56, then @varAmt now holds 1234.56.

Perhaps you are using this in a special report that must be follow a fixed length specification, with 15 spaces allocated to this total padded with zeroes, with no commas or decimal point.

You can assign your @varAmt variable to another variable and apply formatting in the following way.

@varTotal* = @varAmt<015>

When you use @varTotal in your report, it will allocate 15 spaces for this value, filling any empty spaces with zeroes as needed so that the fixed length output is preserved. The decimal point is removed with this particular format.

If @varAmt is 1234.56 then @varTotal will be 000000000123456.

Top of page.

Summary

Working with variables gives you many possibilities when writing reports.

tip.gif The examples in this topic are enabled in Collect! Version 11.4 Build 3.4 and newer.

You can assign a field to a variable or you can assign one variable to another. You can apply formatting to the field or variable during the assignment. All operators for formatting text and numeric fields may be used. The value is stored as formatted text string in a String variable. Formatting variables may be used in special reports for electronic data submission in any kind of designated fixed format.

tip.gif There are several Help topics on formatting fields and variables. Each data type, for instance text or numbers, has several commands that you can use to apply formatting when you assign or print your variable.

Top of page.

See Also

- How To Format Numeric Fields and Numeric Variables
- How to Format Text Fields and Text Variables
- How To Format Date Fields and Date Variables
- Report Sample to view sample reports and letters
- Report Topics Index for a list of all report and letter topics

Top of page.

Was this page helpful? Do you have any comments on this document? Can we make it better? If so how may we improve this page.

Please click this link to send us your comments: helpinfo@collect.org