Important Note: It is very important that you backup your Reports before doing any modifications so you have a copy of the Reports before your modifications. This is so if you make a mistake and you cannot figure out how to fix it you can restore the Reports and start from scratch. It is also important to Backup your Reports once you have modified and tested to be sure your modifications work. If you save the Reports twice in one day you will need to rename the backup slightly so it does not overwrite your first backup as the default Report file name is MGMREPS20051220.zip (the 20051220 represents the date of 12/20/2005 and the system changes this daily).
Labels and Reports are very similar in how they function and how to modify them. We recommend you read the following topics in addition to this topic before doing any modifications. See the Modify Report Layout, Modify Label Layout, Add Toolbars to Reports, Show Builds and Variables, and Envelope help topics for more information on modifying reports and labels.
When you modify a report, many objects will have functions embedded in them.
The most common functions you will see in reports are:
The Alltrim function takes any leading and trailing spaces off of a character string. (There are also commands LTRIM() and RTRIM() to remove spaces from the left or right side of a character string.)
This function is discussed in some detail in the Modify Report Layout help topic.
This function returns the maximum value of two or more numbers. In the Receipt layout, you will see an entry that reads MAX(cuDetail.Price,cuDetail.Pricewas)
This function returns the greater of the actual price the piece was sold for (price), or the original asking price (pricewas)
There is also a MIN() command that works in the same way but returns the lesser of two values.
The STR function takes a number and turns it into characters. Believe it or not, there is a difference between the number 12 and the characters "1" and "2" put together in a character string.
When you convert a number to a character string, you can also specify the length of the field and the number of decimal places. So, the function STR(246,12,2) would return a character string of " 246.00" (note the six leading spaces)
IIF(logical, character, character)
The IIF function is a wonderful tool for printing different values at different times. In the Receipt layout, you will see an entry that reads:
IIF((cuDetail.Pricewas > cuDetail.Price) , 'Discount: $' + alltrim(str(cuDetail.Pricewas - cuDetail.Price,12,2)),"")
In English, this statement would read, IF the "pricewas" is greater than the "price", print the amount of the discount, otherwise, don't print anything.
In the iff statement IIF(A,B,C) we would say, "If A is true, then print B, otherwise print C.
Most dates that are used in Masterpiece are actually DateTime fields. In order to print just the date portion of a DateTime field, we use a function.
This function is called the Time To Date function.
TTOD(12/25/00 08:10:05) would return just 12/25/00
Related functions are
DTOC() Date to Character
CTOD() Character to Date
CTOT() Character to DateTime
There is a special system variable that stores the page number. To put a page number on a report, you simply create a text box on the report and include a line like the following:
"Page: " + alltrim(str(_pageno))
This says, print the word "Page:" and then print the string equivalent of the page number without any spaces.
The underline ( _ ) before the word pageno is very important.