(Comp.sys.handhelds) Item: 2264 by fseipel at hpuxa.ircc.ohio-state.edu Author: [Frank Seipel] Subj: HP-48SX; subroutine (subscripted chemical formulae) Date: Thu Feb 28 1991 Chemical Formula Display Utility (CFD) by Frank Seipel The following is a short RPL subroutine, to be called CFD, and a short example program, Call, which demonstrates its use. The purpose of CFD is to provide a means of displaying subscripted chemical formulae in user programs. CFD takes three arguments, an x-coordinate (binary integer), a y-coordinate (binary integer), and a text string (formula to display). The formula will be superimposed on PICT, beginning at the location specified by your coordinates. Any numerals in the formula will be subscripted, so as to appear like a chemical formula you would write on paper. Optionally you may include an '@' character in the string. This is interpreted as: go to column #50d and add the rest of the string to PICT at once, without subscripts -- this may be useful in right-justifying the names of compounds next to their names (see example program). See page 324 of the manual for a diagram showing the binary coordinate system; the upper left corner is { #0d #0d }, the bottom right corner is { #130 #63 }. To type '@' on the HP-48SX, key in: alpha, followed by blue shift, and then ENTER. I realize this program is rather straightforward, but it seems as if it would be something which will be written over and over by many people so I decided to post it to the net. I am working on a program to let you scroll through subscripted formulas of common compounds. Once I have this working I will write a program to compute specific enthalpy at a given temperature, and to display other physical properties such as boiling points, heats of formation, vaporization, and combustion. If you didn't guess, YES, I am studying Chemical Engineering... ---------------- STO this program as 'Call' ------------------------ %%HP: T(3)A(R)F(.); \<< # 0d # 22d "H2SO4@Sulfuric Acid" CFD { } PVIEW \>> ---------------- Second example ------------------------------------ Example calling sequence: 4: #0d 3: #0d 2: "CH3CH2CH3@Propane" 1: CFD Then hit orange-shift-graph to display PICT to see the subscripted formula in the upper right hand corner of screen. See also 'Call', above. Note: You may wish to adjust how far '@' goes over horizontally, depending on the length of your formula.