home *** CD-ROM | disk | FTP | other *** search
- <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
- <html>
-
- <head>
- <meta http-equiv="refer" content="file:coolcalc.htc">
-
-
-
- <title>Advanced Customization</title>
- </head>
-
- <body bgcolor="#FFFFFF">
-
- <h2>Advanced Customization </h2>
-
- <p>Many of you won't need or want to get this deep into CoolCalc,
- but if you're really into creating your own custom formula
- screens or custom calculators, this section is for you.</p>
-
- <p>This section answers the following questions:</p>
-
- <dl>
- <dt>What's the easiest way to create a formula screen?<br>
- What are variables, and how do they work?<br>
- Example: Creating a conversion screen<br>
- Example: Creating a calculation screen<br>
- </dt>
- </dl>
-
- <h3>What's the easiest way to create a formula screen?</h3>
-
- <blockquote>
- <p>Formula screens come in two different types: conversions,
- and calculations. An example of a conversion is the metric
- conversion screens, i.e. converting temperature from Celsius
- to Fahrenheit. Calculations are like the Loans screen, where
- you enter the term, interest rate, and monthly payment, and
- the amount you can borrow is calculated for you.</p>
- <p>There are two templates you can use to create your own
- formula screens: <strong>conversion template.mac</strong>,
- and <strong>formula template.mac</strong>. Choose the
- template that best matches the type of calculation you wish
- to produce.</p>
- </blockquote>
-
- <h3>What are variables, and how do they work?</h3>
-
- <blockquote>
- <p>As with any formula, CoolCalc's formula screens require
- you to use variables. If you look at some of the buttons in
- the formula screen templates, you'll see two functions being
- used: _ShowVariable, and _SetVariable. The parameter to these
- functions is always the name of the variable (variable names
- are case sensitive). _ShowVariable displays the value of a
- particular variable (using the Format property of the
- button). _SetVariable assigns the value of a variable to the
- contents of the display. </p>
- <p>The variable functions are useful when creating formula
- screens because you can use them to store and retrieve values
- while recording macros. For doing conversions, the
- _SetVariable buttons will be replaced with a macro that sets
- all variables on the screen. For calculations, the ? buttons
- will be replaced with macros that set variables.</p>
- </blockquote>
-
- <h3>Example: Creating a conversion screen</h3>
-
- <blockquote>
- <p>We'll show you the steps we took to create the metric
- weight conversion utility that ships with CoolCalc. The
- technique we use is to modify conversion template.mac to our
- specific conversion. In this example, we'll first create a
- macro that takes ounces, and converts that value to pounds,
- grams, and kilograms. Next, for grams, we'll convert that
- value to ounces, and run the ounces macro again to fill in
- the rest of the values. We'll repeat this process for
- kilograms and pounds.</p>
- </blockquote>
-
- <ol>
- <li>Select <strong>File</strong>, <strong>Open</strong> from
- the top menu, and open <strong>"conversion
- template.mac"</strong>. </li>
- <li>Save the template as <strong>test.mac</strong>. To do
- this, select <strong>File, Save As</strong> from the top
- menu, and enter "test".</li>
- <li>Decide which variables you will want. For this example,
- we'll use grams (g), kilograms (kg), ounces (oz) and
- pounds (lbs).</li>
- <li>Select <strong>View, Program Mode</strong> from the top
- menu.</li>
- <li>Delete the extra fields you don't need. Eight fields are
- shown, and we only need four of them, so delete the
- buttons labeled a, e, d, h, and the display buttons next
- to them as well. (To delete a button, <strong>tap on it
- once</strong>, then select <strong>Edit, Delete Button</strong>
- from the top menu.)</li>
- <li>Change the title of the layout to "weight
- conversion". To do this, select <strong>File,
- Properties</strong> from the top menu, and enter
- "weight conversions" in the title field. Press
- OK when finished.</li>
- <li>Change the appearance of the variable buttons. Hold down
- the Alt key and tap the button labeled "b", and
- set the Alt. Keycap field to "g". Press OK.
- Change the buttons labeled "c" to
- "kg", "f" to "oz" and
- "g" to "lbs" in the same way.</li>
- <li>Return to Run Mode. (Select <strong>View, Run Mode</strong>
- from the top menu).</li>
- <li>Now, we record the macro that takes a value for ounces,
- and calculates the number of pounds, grams, and
- kilograms. First, press 1 to start the macro with a
- value. Next, select <strong>Macro, Record Macro</strong>
- from the top menu. When asked for the name of the macro,
- type "test-oz". </li>
- <li>The macro gets recorded as follows: press oz, then the
- division button, then 16, = and press lbs to set the
- value for pounds. Tap the button to the right of oz to
- return the ounces value to the display, press X 28.35 =,
- then press the button labeled g to set grams. Press the
- division key, then 1000, then = and press the button
- labeled kg to set kilograms. </li>
- <li>Select <strong>Macro, End Record Macro</strong> to end
- the macro. When you are prompted "OK to assign next
- button pressed to new macro?", answer Yes. Tap the
- button labeled oz to assign the new macro to the oz
- button. We've just completed a quarter of the process;
- now, if you enter a number then press the oz button, you
- will have converted ounces to pounds, grams and
- kilograms. Note that the oz button will read test-oz. You
- can change this by returning to Program Mode (select <strong>View,
- Program Mode</strong> from the top menu), then hold down
- the Alt key and tap on the test-oz button, and then enter
- oz in the Alt. Keycap field. Be sure to return to Run
- Mode (Select <strong>View, Run Mode</strong> from the top
- menu).</li>
- <li>Next, we can record a macro for pounds. Press 1 to start
- the macro with a value, then select <strong>Macro, Record
- Macro</strong>. When asked for the name of the macro,
- enter "test-lbs". </li>
- <li>Now we actually record the macro for pounds. This is
- easy, we simply convert to ounces by multiplying by 16,
- and then let the ounces macro test-oz do the rest. Enter
- X, then 16, then =. Now, press the oz button.</li>
- <li>End the macro for pounds: select <strong>Macro, End
- Record Macro</strong> from the top menu. When you are
- prompted "OK to assign next button pressed to new
- macro?", answer <strong>Yes</strong>. Tap the button
- labeled lbs to assign the new macro to the lbs button.
- You should change the name of the button back to lbs like
- we did earlier for the oz button.</li>
- <li>Repeat the same steps for the g and kg buttons; for
- grams, divide by 28.35 to set ounces, and run the oz
- macro. For kilograms, you can just divide by 1000, and
- run the g macro you just recorded.</li>
- <li>Save your work. (From the top menu, select <strong>File,
- Save</strong>).</li>
- <li><strong>Advanced stuff: </strong>if you want to make a
- custom help file for your new test layout screen, you
- will need to make a HTML file called
- "cc-test.htp", and place it in your \Windows
- directory on your HPC. (All help files for Coolcalc
- screens start with "cc-" and end with
- ".htp". Creating HTML files can be done using
- Microsoft Word or other commercially available software,
- but the specifics are beyond the scope of this document.</li>
- </ol>
-
- <blockquote>
- <p><br>
- That's it! You can use these same steps and tricks to create
- conversion screens of your own. Remember the key concepts:
- first, use the "conversion template.mac" layout as
- a starter for all of your conversions, and second, once you
- make your first macro, you can let it do most of the work
- when you create the other macros. Also, it's a good idea to
- keep a consistent naming scheme among your macros and
- layouts. Note how we named the layout macro test, and the
- calculation macros test-oz, test-lbs, etc. Following this
- convention will make life a lot easier for you as you add to
- your collection of custom conversion screens.</p>
- </blockquote>
-
- <h3>Example: Creating a calculation screen</h3>
-
- <blockquote>
- <p>Calculation screens are a nice way to present what-if
- scenarios in a pleasing way. For example, the loans screen
- that comes with CoolCalc is a nice example of a calculation
- screen. You enter values for the known variables, then press
- the ? button next to the unknown value, and the result
- appears. Creating calculation screens is a bit simpler than
- creating conversion screens. Use the file <strong>formula
- template.mac</strong> as a basis for your custom calculation
- screens. Again, as we did with the conversion example, be
- sure to use a consistent naming convention for your layouts
- and macros, i.e. if the layout is named xyz, and xyz used
- variables var1 and var2, name your macros that go with the
- layout xyz-var1, xyz-var2 etc.</p>
- <p>For our example, we'll do a simple margin calculation as
- would be used in a retail setting. Our variables are margin,
- price, and cost. The formulas we will use will be:</p>
- <p>margin=((price - cost)/cost) x 100.</p>
- <p>price = cost / (1 - (margin/100))</p>
- <p>cost = price x (1 - (margin/100))</p>
- <p><strong>Here's how to do it:</strong></p>
- </blockquote>
-
- <ol>
- <li>Open <strong>formula template.mac</strong>. (From the top
- menu, select <strong>File, Open</strong>, and choose <strong>"formula
- template.mac"</strong>).</li>
- <li>Select Program Mode. (From the top menu, select <strong>View,
- Program Mode</strong>).</li>
- <li>Save the template as "margin.mac" (From the top
- menu, select <strong>File, Save As</strong>, and type
- "margin". Then, press Enter.</li>
- <li>Change the title of the screen to "margin
- calculations". (From the top menu, select <strong>File,
- Properties</strong>, and enter "margin
- calculations" in the title field. Press OK.)</li>
- <li>Remove any excess variables. Since four variables are
- showing, and we need only three, delete the button
- labeled "d", and the two buttons next to it.
- (Select the "d" button, then from the top menu,
- select <strong>Edit, Delete Button</strong>. Press the
- enter key when prompted "Press OK to delete this
- button". Repeat for the two buttons next to the
- "d" button.) </li>
- <li>Change the a button to reflect the cost variable. (Hold
- down the Alt key, and tap the button labeled
- "a". Change the parameter from "a" to
- "cost".)</li>
- <li>Change the button to the right of the cost button to
- display the cost variable. (Hold down the Alt key, and
- tap the button to the right of the cost button. Change
- the parameter from a to cost.)</li>
- <li>Repeat the previous two steps to change the b button and
- the button to it's right to price. Also, change the c
- button and the button to it's right to margin.</li>
- <li>Now, we can start to record macros. First, we need to
- return to Run Mode. (From the top menu, select <strong>View,
- Run Mode</strong>.)</li>
- <li>Let's create the macro to calculate margins. First we
- need to seed the cost and price variables. We'll set cost
- to 80, and price to 100, and this should give us a margin
- of 20%. Press the 80 buttons, and then the button labeled
- cost. Press 100, and then the price button.</li>
- <li>Now we'll program the formula margin=((price -
- cost)/cost) x 100, and assign it to the ? button to the
- right of the margin button. Start the macro by selecting <strong>Macro,
- Record Macro</strong> from the top menu. Enter the name
- of the macro as margin-margin.</li>
- <li>Do the formula. Press the button to the right of the
- price button, then -, then the button to the right of the
- cost button, then the division button, then the button to
- the right of the price button, then the X button, then
- 100. If you see 20.00 in the display, press the margin
- button.</li>
- <li>End the macro and assign it to a key: from the top menu,
- select <strong>Macro, End Record Macro</strong>. Answer
- Yes when asked "Want to assign next button pressed
- to new macro?". Tap the button labeled ? to the
- right of the margin button.</li>
- <li>Repeat this process for the buttons labeled ? to the
- right of the cost and price buttons, but use the formulas
- for cost and price. Make sure to call the macros
- margin-cost and margin-price respectively. (Hint: if you
- don't have the necessary buttons on screen to do the
- formula, try the Edit, Execute Function menu selection.
- In this example, you may need to use the Change Sign
- function or the Left Parenthesis function. You can also
- assign these functions to one of the empty buttons while
- you are recording a macro as well by going in and out of
- Program Mode.)</li>
- <li>When you're finished with the macros, you'll want to
- change the macro buttons back to their appearance of ? .
- To do so, select <strong>View, Program Mode</strong> from
- the menu, hold down Alt and tap the buttons, and set the
- Alt. Keycap field to "?".</li>
- <li>Save the layout! From the top menu, select <strong>File,
- Save</strong>.</li>
- <li>Return to Run Mode, and test your screen. (Select <strong>View,
- Run Mode</strong> from the top menu).</li>
- </ol>
-
- <blockquote>
- <p><br>
- That's it! You can enter 80 for cost, 100 for price, and you
- should get 20 for the margin. Press the ? buttons next to
- price and cost to test these calculations as well.</p>
- <p><strong>More advanced stuff:</strong> you change the
- format of your display fields to show a money display. From
- Program Mode, edit the property of the buttons to the right
- of the cost and price buttons and set the format to Money.
- Return to Run Mode to see if you like how it looks.</p>
- <p><strong>Really advanced stuff:</strong> you can also
- change the number of digits (precision) of all values
- displayed. For this screen, a single digit after the decimal
- should suffice. From Run Mode, select Edit, Execute Function
- from the top menu. Change the function to _Precision, and set
- the parameter to the number of digits you wish to display (1
- in this case). Press OK, and the margin value and display
- will change to show one digit of precision. Make sure to save
- the layout to keep the precision value.</p>
- </blockquote>
- </body>
- </html