mrc Documentation
michaels, ross & cole, ltd.
http://www.mrc-productivity.com/

Constant Calculations

Constant calculations (calcs) are a great technique when you are trying to get a constant field written to a file/the screen to work calculations. For example, you would like to compute the difference in days from the value written in the file to one a user prompts the application with. Using m-Painter & making a few simple changes you can make this happen too.

How to Work with Constant Calcs

The key to constant calc fields is that when you create it, you are merely creating a holder that will hold a value for later. In our case, the "later" will be when the user inputs data at the prompt screen.

To create this place holder, go to the Calculations screen. At the calculation definition screen, enter *CONST in the description field. For length and decimal, choose appropriate values. (In our case, we will be using the Java Date Translator, so our output needs to be 8,00. In the CALCULA001 = field, set the equation equal to itself. See below:





Now that we have defined the constant, you will now need to set up the calculation that will handle your date conversion. mrc offers a java date translator that can handle this for you.

Next, it is time to set up your record selection.





Make any other needed changes to your application and then click build/compile. You probably do not want the date to appear on every line, so you may want to go into the pre-format screen and set Print to No for your *CONST field.

Before we utilize our constant calculation, we will need to paint. Open the painter application, and change your view to the prompt screen (Located in the dropdown box on the m-Painter toolbar). Switch to Source view.

Directly above the </head> tag, add this text:
<script language="JavaScript">
function getvalue(){
document.FORM_RXXXXX.CALCULA001.value=document.FORM_RXXXXX.R001.value;
}
</script>

Additionally, you will need to add
onsubmit="getvalue();"
to the form line so it will look like this:
<form action="DATADICTIONARY.RXXXXXs" method="post" name="FORM_RXXXXX" onsubmit=”getvalue();”>

This will set CALCULA001 to whatever the user entered on the prompt screen. Click save.

You are now done. Run your application.