HP 48 Currency Converter Key Assignment by Jeremy Smith This key assignment allows conversion between the currencies of 52 countries. Pressing CST displays the (first six) flags of all 52 countries in the menu bar. Pressing a number followed by a flag puts the quantity and denomination in level one. Pressing left-shift (orange) and a different flag will convert to the correct quantity and denomination of the new country. For example, pressing 3 and the Australian flag (CST B) puts 3_$A on level one. Pressing left-shift (orange) and the Canadian flag (NXT B) converts it to 2.69_Can$ in level one. Amounts may be added no matter what currency each amount is, with automatic conversion to whatever currency is in level one. For instance, 3_$A in level two added to 3_Can$ in level one yields 5.69_Can$ in level one. Technical Details The money directory contains the variable CST (2945.5 bytes) and 52 currency variables (312 bytes). CST is a list of 52 items, each item being a list of the form { GROB 21x8 '1_$A' }. The GROB is the flag graphic and the '1_$A' is the currency. The corresponding variable in this case is '$A', which has a value of 0.785_$. All the currency variables are defined in terms of US$ (1_$). The US dollar is (arbitrarily) defined as 1_mol since this built- in basic SI unit is one of quantity and therefore less unrelated to currency than any other basic SI unit. By defining currency as a built-in unit conversions are handled automatically by the machine (fast, accurately and simply) just like built-in units. UBASE() on any amount reduces it to moles, but the result can be converted back into units of currency with the regular currency conversions on CST. A disadvantage is that it is as trivial to generate multiples, divisions and powers of currency units (alone and in combinations). 10_$^2 is meaningless but ( 10_$ / 2_Can$ ) 5_$/Can$ can be reduced using UBASE() to 5.7182, the amount of Can$ in 5 US$. The 52 countries, currencies and currency symbols are listed as comments at the end of the directory listing below. Some currency symbols conflict with built-in units and so alternatives were chosen; these are listed in the table. There is an additional directory 'Flags' (2472 bytes) which contains the 52 flag GROBs named by country. It also contains a small program 'Grab' which grabs the top left 21x8 pixels of the current PICT to a GROB in level 1. I used this to draw and save all the flags for the menus. This whole subdirectory is not necessary for the operation of the currency conversion key assignment and can be deleted (to save >2472 bytes). It is handy for editing nd keeping copies of the flags. Adding new currencies is simply a matter of adding a new two part list to the CST list, and also storing a corresponding variable with the correct value defined in dollars (or any other valid denomination). If you actually use this converter you'll probably want to (drastically) reduce the number of conversions available. Simply remove each two part list from the CST list, and the corresponding variable. There is no on-line help regarding what country any currency or flag belongs to. Refer to the table. By tagging the GROBs in the CST list with the country name, or just replacing the GROB with a string for the country, the country name appears in the menu instead of the flag. For practical use this might be more expedient. I discovered these two methods in trying to tag the GROB for documentation purposes, and using a variable to reference the GROB since it would be simpler to edit a GROB by itself rather than the ungainly CST variable. Unfortunately, those names showed up in the menus instead of the graphic. I was unable to find pictures of flags for Bahrain, Jordan, Kuwait, and Taiwan, so I have substituted a `test-pattern'. Feel free to generate these, and improve on any other of the graphics. The countries represented are mostly those that are listed daily in the (Foreign) Exchange Rates column in the Wall Street Journal. Use this to keep the exchange rates current. I think I'll try writing a program next. smithj@jacobs.cs.orst.edu 9/9/91