From: smithj@jacobs.CS.ORST.EDU (Jeremy Smith)
Newsgroups: comp.sources.hp48
Subject: v01i037:  currency - Currency converter v1.0, Part01/01
Date: 15 Sep 91 21:40:49 GMT
Followup-To: comp.sys.hp48

Checksum: 4002925325 (verify with brik -cv)
Submitted-by: Jeremy Smith <smithj@jacobs.CS.ORST.EDU>
Posting-number: Volume 1, Issue 37
Archive-name: currency/part01

BEGIN_DOC currency.doc

                 HP 48 Currency Converter Key Assignment

       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 result in
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 <Jeremy |-) Smith> 9/9/91

# 526Ch
7034.5
END_DOC

BYTES: #526Ch 7037.5

BEGIN_RPL currency
%%HP: T(3)A(D)F(.);
DIR
  \194 '.0001003_$'
  $A '.785_$'
  Sch '.0813_$'
  BD '2.6525_$'
  BF '.02781_$'
  Cz$ '.00269_$'
  \163 '1.681_$'
  Can$ '.8744_$'
  Ch$ '.002929_$'
  Y '.187017_$'
  Col$ '.001848_$'
  DKr '.1483_$'
  S\180 '.000966_$'
  Fmk '.23498_$'
  FF '.16858_$'
  DM '.5724_$'
  \208r '.005181_$'
  HK$ '.12879_$'
  Re '.03857_$'
  Rp '.0005097_$'
  \163Ir '1.5295_$'
  I\163 '.4037_$'
  L '.0007666_$'
  \165 '.00731_$'
  Doubloon '1.05_\163'
  JD '1.45_$'
  KD '3.4014_$'
  L\163 '.00112_$'
  M$ '.3594_$'
  \163M '2.994_$'
  Mex$ '.0003282_$'
  f '.5083_$'
  $NZ '.5745_$'
  NKr '.1465_$'
  PRe '.0406_$'
  I\180 '1.2048_$'
  \254 '.0381_$'
  Esc '.006684_$'
  SRI '.26663_$'
  S$ '.58_$'
  Rand '.3472_$'
  w '.0013657_$'
  Pta '.009187_$'
  SKr '.1578_$'
  SwF '.6566_$'
  T$ '.037439_$'
  Bht '.0389_$'
  \163T '.0002176_$'
  \208h '.2723_$'
  $ '1_mol'
  Ur$ '.000471_$'
  B '.01709_$'
  CST { {
GROB 21 8 FFFFF1FFFFF1000000006000006000000000FFFFF1FFFFF1
'1_\194' } {
GROB 21 8 AEFFF11FF7F14EFFF11FFBE1AEFFF1FFFFB13FF7F1FFFFF1
'1_$A' } {
GROB 21 8 FFFFF1FFFFF1000000000000000000FFFFF1FFFFF1FFFFF1
'1_Sch' } {
GROB 21 8 D6BD61BD6BD06BD6B1D6BD61BD6BD06BD6B1D6BD61BD6BD0
'1_BD' } {
GROB 21 8 F30F30F30F30F30F30F30F30F30F30F30F30F30F30F30F30
'1_BF' } {
GROB 21 8 FFBFF1FF0EF1F7ECF1F3E8F1F7ECF1FF0EF1FFBFF1FFFFF1
'1_Cz$' } {
GROB 21 8 C86130036C000C6300CFFF30CFFF300C6300036C00C86130
'1_\163' } {
GROB 21 8 F00870F02870F07870F07870FCA970FCF970F02870F02870
'1_Can$' } {
GROB 21 8 B70000160000370000F70000555551FFFFF1555551FFFFF1
'1_Ch$' } {
GROB 21 8 FFFFF1BBFFF116FFF13FFFF1F7FFF1FDFFF1FFFFF1FFFFF1
'1_Y' } {
GROB 21 8 555551AAAAA0555551FFFFF1FFFFF1FFFFF1555551FFFFF1
'1_Col$' } {
GROB 21 8 F7FFF1F7FFF1F7FFF1000000F7FFF1F7FFF1F7FFF1F7FFF1
'1_DKr' } {
GROB 21 8 555551AAAAA0555551AAAAA0FFFFF1FFFFF1555551FFFFF1
'1_S\180' } {
GROB 21 8 081000081000081000FFFFF1FFFFF1081000081000081000
'1_Fmk' } {
GROB 21 8 F30A20F30F30F30A20F30F30F30A20F30F30F30A20F30F30
'1_FF' } {
GROB 21 8 FFFFF1FFFFF1FFFFF1555551FFFFF1555551AAAAA0555551
'1_DM' } {
GROB 21 8 BFFF70B300000CFF70B30000BFFF70000000FFFF70000000
'1_\208r' } {
GROB 21 8 AEFFF15DFFF1AEFFF15DFFF1AEFFF1FFFFF1FFFFF1FFFFF1
'1_HK$' } {
GROB 21 8 555551AAAAA000600000F00000F000006000FFFFF1FFFFF1
'1_Re' } {
GROB 21 8 FFFFF1FFFFF1FFFFF1FFFFF1000000000000000000000000
'1_Rp' } {
GROB 21 8 510600A20030510900A20600510030A20900510600A20030
'1_\163Ir' } {
GROB 21 8 FFFFF100400008F30000110008F300004000000000FFFFF1
'1_I\163' } {
GROB 21 8 F30A20F30510F30A20F30510F30A20F30510F30A20F30510
'1_L' } {
GROB 21 8 FFFFF110000110C00110E10110E10110C001100001FFFFF1
'1_\165' } {
GROB 21 8 FF1FF1FF0EF1FFAEF1FB1BF1F71DF1FFEEF1FF5FF1FFBFF1
'1_Doubloon' } {
GROB 21 8 0000006BD6B16BD6B10000006BD6B16BD6B10000006BD6B1
'1_JD' } {
GROB 21 8 9429406BD6B16BD6B19429406BD6B16BD6B19429406BD6B1
'1_KD' } {
GROB 21 8 FFFFF1FFFFF100800000C10000E30000C000FFFFF1FFFFF1
'1_L\163' } {
GROB 21 8 FFFFF17F0000BDFFF1BF00007FFFF1000000FFFFF1000000
'1_M$' } {
GROB 21 8 008FF1808FF1C18FF1638FF1C18FF1808FF1008FF1008FF1
'1_\163M' } {
GROB 21 8 FF0CF1FFCCF1FFEDF1FFDFF1FF2DF1FFCCF1FF0CF1FF0CF1
'1_Mex$' } {
GROB 21 8 555551AAAAA0555551000000000000FFFFF1FFFFF1FFFFF1
'1_f' } {
GROB 21 8 AEFFF11FF7F14EFFF11FFBE1AEFFF1FFFFF1FFF7F1FFFFF1
'1_$NZ' } {
GROB 21 8 F7DFF1F7DFF1001000FFFFF1001000F7DFF1F7DFF1F7DFF1
'1_NKr' } {
GROB 21 8 0FFFF10F7FF10FBBF10FBFF10FBFF10F7BF10FFCF10FFFF1
'1_PRe' } {
GROB 21 8 F70CF1F70CF1F70CF1F70CF1F70CF1F70CF1F70CF1F70CF1
'1_I\180' } {
GROB 21 8 EFFFF1CFFFF18FFFF16FFFF16AAAA00555518AAAA0455551
'1_\254' } {
GROB 21 8 51CFF1AEBFF15AAFF1AEBFF15AAFF1ACDFF151EFF1AAFFF1
'1_Esc' } {
GROB 21 8 FFFFF1FFFFF1F953F1F300E1F795F1FFFFF1F108F1FFFFF1
'1_SRI' } {
GROB 21 8 FFFFF17AEFF13FBFF13BFFF17EEFF1FFFFF1000000000000
'1_S$' } {
GROB 21 8 555551AAAAA00000000CF300006000000000FFFFF1FFFFF1
'1_Rand' } {
GROB 21 8 080400041A0008C40000E10000E10008C400041A00080400
'1_w' } {
GROB 21 8 FFFFF1FFFFF1FFFFF1000000000000FFFFF1FFFFF1FFFFF1
'1_Pta' } {
GROB 21 8 F7CFF1F7CFF1F7CFF1000000000000F7CFF1F7CFF1F7CFF1
'1_SKr' } {
GROB 21 8 FFFFF1FF1FF1FF1FF1F308F1F308F1FF1FF1FF1FF1FFFFF1
'1_SwF' } {
GROB 21 8 942940429421294290942940429421294290942940429421
'1_T$' } {
GROB 21 8 AAAAA0555551000000FFFFF1FFFFF1000000AAAAA0555551
'1_Bht' } {
GROB 21 8 FFFF30F1FF30FCFF30FCDF30FC9F30FCFF30F1FF30FFFF30
'1_\163T' } {
GROB 21 8 BDAAA0D655516BAAA0B50000D600006BFFF1BDFFF1DEFFF1
'1_\208h' } {
GROB 21 8 A200005DFFF1A200005DFFF1A20000FFFFF1000000FFFFF1
'1_$' } {
GROB 21 8 800000CDFFF1E30000CDFFF1800000FFFFF1000000FFFFF1
'1_Ur$' } {
GROB 21 8 555551AAAAA0FF0FF1F76EF1F7FEF1D6BD61BD6BD0D6BD61
'1_B' } }
  Flags
    DIR
      Argentina
GROB 21 8 FFFFF1FFFFF1000000006000006000000000FFFFF1FFFFF1
      Australia
GROB 21 8 AEFFF11FF7F14EFFF11FFBE1AEFFF1FFFFB13FF7F1FFFFF1
      Austria
GROB 21 8 FFFFF1FFFFF1000000000000000000FFFFF1FFFFF1FFFFF1
      Bahrain
GROB 21 8 D6BD61BD6BD06BD6B1D6BD61BD6BD06BD6B1D6BD61BD6BD0
      Belgium
GROB 21 8 F30F30F30F30F30F30F30F30F30F30F30F30F30F30F30F30
      Brazil
GROB 21 8 FFBFF1FF0EF1F7ECF1F3E8F1F7ECF1FF0EF1FFBFF1FFFFF1
      UK
GROB 21 8 C86130036C000C6300CFFF30CFFF300C6300036C00C86130
      Canada
GROB 21 8 F00870F02870F07870F07870FCA970FCF970F02870F02870
      Chile
GROB 21 8 B70000160000370000F70000555551FFFFF1555551FFFFF1
      China
GROB 21 8 FFFFF1BBFFF116FFF13FFFF1F7FFF1FDFFF1FFFFF1FFFFF1
      Colombia
GROB 21 8 555551AAAAA0555551FFFFF1FFFFF1FFFFF1555551FFFFF1
      Denmark
GROB 21 8 F7FFF1F7FFF1F7FFF1000000F7FFF1F7FFF1F7FFF1F7FFF1
      Ecuador
GROB 21 8 555551AAAAA0555551AAAAA0FFFFF1FFFFF1555551FFFFF1
      Finland
GROB 21 8 081000081000081000FFFFF1FFFFF1081000081000081000
      France
GROB 21 8 F30A20F30F30F30A20F30F30F30A20F30F30F30A20F30F30
      Germany
GROB 21 8 FFFFF1FFFFF1FFFFF1555551FFFFF1555551AAAAA0555551
      Greece
GROB 21 8 BFFF70B300000CFF70B30000BFFF70000000FFFF70000000
      HongKong
GROB 21 8 AEFFF15DFFF1AEFFF15DFFF1AEFFF1FFFFF1FFFFF1FFFFF1
      India
GROB 21 8 555551AAAAA000600000F00000F000006000FFFFF1FFFFF1
      Indonesia
GROB 21 8 FFFFF1FFFFF1FFFFF1FFFFF1000000000000000000000000
      Ireland
GROB 21 8 510600A20030510900A20600510030A20900510600A20030
      Israel
GROB 21 8 FFFFF100400008F30000110008F300004000000000FFFFF1
      Italy
GROB 21 8 F30A20F30510F30A20F30510F30A20F30510F30A20F30510
      Japan
GROB 21 8 FFFFF110000110C00110E10110E10110C001100001FFFFF1
      JollyRoger
GROB 21 8 FF1FF1FF0EF1FFAEF1FB1BF1F71DF1FFEEF1FF5FF1FFBFF1
      Jordan
GROB 21 8 0000006BD6B16BD6B10000006BD6B16BD6B10000006BD6B1
      Kuwait
GROB 21 8 9429406BD6B16BD6B19429406BD6B16BD6B19429406BD6B1
      Lebanon
GROB 21 8 FFFFF1FFFFF100800000C10000E30000C000FFFFF1FFFFF1
      Malaysia
GROB 21 8 FFFFF17F0000BDFFF1BF00007FFFF1000000FFFFF1000000
      Malta
GROB 21 8 008FF1808FF1C18FF1638FF1C18FF1808FF1008FF1008FF1
      Mexico
GROB 21 8 FF0CF1FFCCF1FFEDF1FFDFF1FF2DF1FFCCF1FF0CF1FF0CF1
      Netherlands
GROB 21 8 555551AAAAA0555551000000000000FFFFF1FFFFF1FFFFF1
      NZ
GROB 21 8 AEFFF11FF7F14EFFF11FFBE1AEFFF1FFFFF1FFF7F1FFFFF1
      Norway
GROB 21 8 F7DFF1F7DFF1001000FFFFF1001000F7DFF1F7DFF1F7DFF1
      Pakistan
GROB 21 8 0FFFF10F7FF10FBBF10FBFF10FBFF10F7BF10FFCF10FFFF1
      Peru
GROB 21 8 F70CF1F70CF1F70CF1F70CF1F70CF1F70CF1F70CF1F70CF1
      Philippines
GROB 21 8 EFFFF1CFFFF18FFFF16FFFF16AAAA00555518AAAA0455551
      Portugal
GROB 21 8 51CFF1AEBFF15AAFF1AEBFF15AAFF1ACDFF151EFF1AAFFF1
      SaudiArabia
GROB 21 8 FFFFF1FFFFF1F953F1F300E1F795F1FFFFF1F108F1FFFFF1
      Singapore
GROB 21 8 FFFFF17AEFF13FBFF13BFFF17EEFF1FFFFF1000000000000
      SouthAfrica
GROB 21 8 555551AAAAA00000000CF300006000000000FFFFF1FFFFF1
      SouthKorea
GROB 21 8 080400041A0008C40000E10000E10008C400041A00080400
      Spain
GROB 21 8 FFFFF1FFFFF1FFFFF1000000000000FFFFF1FFFFF1FFFFF1
      Sweden
GROB 21 8 F7CFF1F7CFF1F7CFF1000000000000F7CFF1F7CFF1F7CFF1
      Switzerland
GROB 21 8 FFFFF1FF1FF1FF1FF1F308F1F308F1FF1FF1FF1FF1FFFFF1
      Taiwan
GROB 21 8 942940429421294290942940429421294290942940429421
      Thailand
GROB 21 8 AAAAA0555551000000FFFFF1FFFFF1000000AAAAA0555551
      Turkey
GROB 21 8 FFFF30F1FF30FCFF30FCDF30FC9F30FCFF30F1FF30FFFF30
      UnitedArab
GROB 21 8 BDAAA0D655516BAAA0B50000D600006BFFF1BDFFF1DEFFF1
      USA
GROB 21 8 A200005DFFF1A200005DFFF1A20000FFFFF1000000FFFFF1
      Uruguay
GROB 21 8 800000CDFFF1E30000CDFFF1800000FFFFF1000000FFFFF1
      Venezuela
GROB 21 8 555551AAAAA0FF0FF1F76EF1F7FEF1D6BD61BD6BD0D6BD61
      Grab
        \<< PICT RCL
{ # 0h # 0h } {
# 14h # 7h } SUB
        \>>
    END
END
@     Country     Currency    Symbol       Symbol used on 48
@     Argentina   Austral     -A          ^A see note 1
@     Australia   Dollar      $A
@     Austria     Schilling   Sch
@     Bahrain     Dinar       BD
@     Belgium     Franc       BF
@     Brazil      Cruzeiro    Cz$
@     UK          Pound            see note 2
@     Canada      Dollar      Can$
@     Chile       Peso        Ch$
@     China       Renminbi    Y
@     Colombia    Peso        Col$
@     Denmark     Krone       DKr
@     Ecuador     Sucre       S/    S'     see note 3
@     Finland     Markka      Fmk
@     France      Franc       F     FF     see note 4
@     Germany     Mark        DM
@     Greece      Drachma     Dr    -Dr   see note 5
@     HongKong    Dollar      HK$
@     India       Rupee       Re
@     Indonesia   Rupiah      Rp
@     Ireland     Punt        Ir
@     Israel      Shekel      I
@     Italy       Lira        L
@     Japan       Yen              see note 6
@     JollyRoger  Doubloon    Doubloon
@     Jordan      Dinar       JD
@     Kuwait      Dinar       KD
@     Lebanon     Pound       L
@     Malaysia    Ringgit     M$
@     Malta       Lira        M
@     Mexico      Peso        Mex$
@     Netherlands Guilder     f
@     NZ          Dollar      $NZ
@     Norway      Krone       NKr
@     Pakistan    Rupee       PRe
@     Peru        New Sol     I/    I'     see note 3
@     Philippines Peso        -P   P      see note 7
@     Portugal    Escudo      Esc
@     SaudiArabia Riyal       SRI
@     Singapore   Dollar      S$
@     SouthAfrica Rand        R     Rand   see note 8
@     SouthKorea  Won         W     w      see note 9
@     Spain       Peseta      Pta
@     Sweden      Krona       SKr
@     Switzerland Franc       SwF
@     Taiwan      Dollar      T$
@     Thailand    Baht        Bht
@     Turkey      Lira        T
@     UnitedArab  Dirham      Dh    -Dh see note 5
@     USA         Dollar      $
@     Uruguay     New Peso    Ur$
@     Venezuela   Bolivar     B
@
@     1.    The symbol for Austral is `A' with a bar through it.  I tried using
@           `A' but the 48 wouldn't take it so I used `^A' with a circumflex
@           on it (#194d).
@
@     2.    `' is the symbol for Pound Sterling (#163d), a crossed Latin `L'.
@
@     3.    The symbols for Sucre and the Peruvian New Sol are `S/' and `I/',
@           respectively.  Since you can't use `/' (division symbol) in a
@           variable name I replaced it with `'' (#180d).
@
@     4.    The 48 wouldn't take `F' so I used `FF'.
@
@     5.    The symbol for Dirham is `Dh', and Drachma is `Dr'.  I tried using
@           `Dh' and `Dr', respectively, but the 48 wouldn't take them so I
@           used `-Dh' and `-Dr', a crossed `D' (#208d) followed by `h' and
@           `r', respectively.
@
@     6.    `' is the symbol for Yen (#165d), a `Y' impaled with a `='.
@
@     7.    The symbol for the Philippine Peso is a `P' with a bar through it. 
@           The 48 wouldn't take P so I used the uppercase Thorn (#254d).
@
@     8.    The 48 wouldn't take an `R' so I spelled out Rand instead.
@
@     9.    The 48 wouldn't take a capital `W' so I put in a small one.

END_RPL

