To order Alpha Four or Alpha Five, click above to go directly to Alpha, or call 800.451.1018 or 781.229.4500
|
|
|
|
|
|
Tuesday, October 1, 2002
|
|
VOLUME 1
ISSUE 8
|
|
|
|
|  |
 |
 |
Conditional Objects - #101
by Barry Rochford
It appears there are some Alpha Five users who have never used a "Conditional Object", and are they are not really certain what it is and what it can do. My objective is to show a way of using a Conditional Object on a Form and on a Report.
Visualize a Conditional Object as a very small spiral bound notebook that you can drag onto your form, report, etc. You can make it large or small as you need. There are multiple blank pages in this notebook, (I think the limit is 32 but it may be more). Each page has a name and a Condition and you can move objects onto each page. If the Condition is True, that page displays whatever you placed on it. Now, back to reality (somewhat anyway).
Using the sample Alpha Sports application that ships with Alpha Five version 5.
You work at Alpha Sports and your Supervisor asks you to complete the following project using the PRODUCT Table.
1. Copy the existing Product Form, naming the copy Product_Test.
2. Calculate the % Markup for each item. Display this field on the form (1 decimal place).
3. If the % Markup is greater than 68% display the comment "Possible Price DECREASE".
4. If the % Markup is less than 48%, display comment "Possible Price INCREASE".
5. All Products with % Markup outside of those ranges will display "Price OK".
Ok, we know what we have to do, so let's get started.
At the Control Panel, Right-click on "Products" Form, then click on Duplicate. When asked, enter "Product_Test" as the new form name.
Next, we must Calculate the % Markup. In case you don't know the formula, it is as follows:
((Retail - Cost) / Retail) * 100 = % Markup
With the formula, you can now drag a new Calculated Summary Field onto the form (right now it doesn't really matter where) , name it "Calc_markup", then click the x-y at the end of the expression entry and the expression builder will pop up. Enter the expression shown above, when complete, verify the expression and answer OK. The Function entry will display "Value". That is what we want, so answer OK. Check the properties of "Calc_markup" on the form, a length of 7 with 1 decimal place should work nicely..
Well, we're on our way! We now have the % Markup, it will display on the form. The only thing left is to display a comment depending on the value of %Markup. Now we are ready to add our Conditional Object!
Remember, we're thinking of a Conditional Object as a very small spiral bound notebook that you drag onto a form (or a report, etc). So go ahead and drag a Conditional Object onto your form. make it approx 1.75" x .75" for now. You will notice from looking at Fig 1 that I moved a couple of the existing fields around. In our case we want to display a page that contains the phrase "Possible Decrease" if our Calculated field named "Calc"markup" is > 68.
Next, if our Calc_Markup field is < 48 we want to display a page that contains the phrase "Possible Increase".
Finally if our Calc_markup field is neither > 68 nor < 48 we want to Default to the phrase "Price OK".
Now we know several things:
- We need 3 "pages" (including the Default). We know the phrase needed for each page.
- We have the two Conditions needed.
Fig 1. Product_Test Form - Design Mode showing the Conditional Object (It does show the "Default" page)
Now you are ready to continue. Right-Click on the Conditional Object (Alpha names it Cond1) click on Properties. Note that there is a little handle on the upper left corner of Cond1.

Fig 2. Cond1 - Properties showing the conditions and the labels
This is where you will enter the Condition and a Label (or name) for each "Page".
Click on the x-y in the condition column, the expression builder appears. Enter the first Condition (use the tools Alpha has provided for you such as F2 etc.).
You want to end up with this as the 1st Condition: Calc->calc_markup > 68. Give it a label of "Decrease" (or whatever you want). The 2nd Condition is similar except; you want Calc->calc_markup < 48 and a label of "Increase". When that is complete, we now need to place the proper phrases that must be displayed on the form.

Fig 3. Right-Click on COND1 to select the page for your Text Objects
Now you need to place a Text Object in each of our 3 pages. Remember the phrases needed and be sure you have the correct phrase on the correct page. The save the form and try it out. Manually check out the Calculation of % Markup, check that the correct phrase is being shown when you have 68% or greater, 48% or lower and some of those in between.
Fig 4. Completed Form Displaying 68.1% Markup and the phrase "Possible Price DECREASE".
I followed the same procedure and made up a Report. It is shown below in Design Mode.

Fig.5 Report using a same Conditional Object as the form.
Hopefully you will become familiar with Conditional Objects now. They can be very useful, they are easy to use, just remember a Conditional Object's "Page" is only selected by a Condition being true.
Barry is an Alpha Developer living near Newtown, PA. He started using Alpha 3 many years ago and has developed many Alpha Five applications for clients as far away as Las Vegas, North Carolina, Long Island and the Catskills of New York. Most Clients are in the Pennsylvania, New Jersey, and New York Metropolitan areas. His applications range from Point Of Sale, to Inventory, Dietary & Recipes, Printing, Garment Manufacturing, Labeling & Mailing, Stockholder Accounting & Employee Stock Purchase as well as the normal Accounts Receivables and Payables.
Barry started using Punch Card Equipment in 1954 while serving in the Air Force, living in Downtown Tokyo across the street from the Imperial Palace. When the IBM 650 Computer was released worked on that and then onto the NCR 304/315 Series. Responsible to the Pacific Command, Directorate of Targets for highly classified computer Projects while spending almost 2 years on the Beaches at Hickam Air Force Base & Pearl Harbor.
Systems Services Manager for NCR Corp. in Columbia, MD then NCR Federal Systems Division in Rockville, MD. Responsible for NCR Equipment at the Bureau of Prisons, USIA, Dept. of Interior and The White House Communications Agency. Finally having enough of transferring, he moved to a Bank in Pennsylvania. Then, in January 1997, having decided life was too short for a 24/7 job, he retired and began Alpha Five Consulting/Programming full time.
Barry Rochford can be contacted at brochford@enter.net
[PRINTER FRIENDLY VERSION]
|
|
| |