JavaScript Calculator - sCal : Calculator « Page Components « JavaScript DHTML

JavaScript DHTML
1. Ajax Layer
2. Data Type
3. Date Time
4. Development
5. Document
6. Event
7. Event onMethod
8. Form Control
9. GUI Components
10. HTML
11. Javascript Collections
12. Javascript Objects
13. Language Basics
14. Node Operation
15. Object Oriented
16. Page Components
17. Security
18. Style Layout
19. Table
20. Utilities
21. Window Browser
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
JavaScript DHTML » Page Components » Calculator 
JavaScript Calculator - sCal

<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin

// ************************************************* sCal2-06r.htm
//
// sCal - small, scientific, script Calculator
//
// Copyright (C) 2003  R. Mohaupt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
// 02111-1307  USA
//                                 --- mgineer1@netscape.net
// ABOUT sCal:                         R.Mohaupt, Feb, 2003
//
//    GENERAL:  sCal is a scientific, programmable calculator form
// --predominately generated in HTML in a relatively short BODY of
// code at the end (approximately the last 20%, depending on how
// much additional code has been added).  The HEAD contains JavaScript
// (JScript, ECMA std.262 Script, or JS) programming language.  
// Therefore, one only needs a JS-enabled web browser (Microsoft
// Internet Explorer, Mozilla, Netscape Navigator, versions 5+, have
// been checked & provided for) to operate sCal, and a text editor
// (usually accessable within the browser) to modify.  The HEAD has
// 3 commented purposes:
//
//    I. CALCULATOR OPERATION FUNCTIONS:  Basic instructions to
// handle I/O (Input / Output) to the calculator form BODY.  These
// are named Ix, Ox, Im, Om etc. {coding convention might have
// named these get_x, put_x, etc.} for I/O to the x-display, memory, 
// etc.  All areas of sCal can be modified by the user;  however,
// special care should be taken in this area since so much other
// code depends on operation of these functions.  The key function
// is "xEval()" which, after some checking for use of the '^' to 
// take x to the y power, calls the JS "eval('string')" function.
//
//    II. MENU GROUPS WITH STRINGS OF JS SOURCE CODE: Operation of
// the menu structure is fairly simple: observing 'Catagory' drop-
// down menus in the upper-right cell of the Calculator BODY, to
// select 'Groups' of individual operations from the drop-down
// menus in the upper-left cell.  Programming this requires some
// study of the included source examples.  As in any coding effort,
// it is VERY important to mimic the location of commas, quotes,
// semi-colons, etc. exactly.  More interesting and challenging is 
// creation of JS-coded strings, often multi-line statements, to
// perform computational desires.  These vary from the application
// of a simple factor (the majority of x}conversions do this) to 
// somewhat elaborate mini-programs, identifiable by some dense
// string construction.  The function "eval" expects a string of
// JS code.  This is what appears in the x-display when the [JS]
// button clicked.  Data additions in *}functions are made in the
// x-display.  Code can be modified there, too.  But for code
// modifications, or addition of new procedures, to become 'per-
// manent', they need to be added to the source.  Here one must
// keep in mind that STRINGS are being built.  Single and double-
// quotes only provide 2-levels.  Prompts in the n[0...19] array
// require another level, hence the supplemental strings of dense
// code appearing immediately before the Group Menu layouts.
//    A few comments are in order here:
//
// *  Operational Summary:  sCal conventions suggest that the 
// following 'codes' be observed.  (The program does not key on
// these, but they give the user a hint of what to expect.)
// x} in description, user click [>x] button to convert or 
//                     operate on value in x-display.
// s} user click [JS] to view text (script) in x-display
// *} click [JS], user seeks comment or other areas in text to 
//             place or replace a value into a procedure, ->[=].
// n} click [JS] to fill-in the n[0..19] array for the program:
//     prompt 'input <' means value to be entered in next column
//     label 'output >' designates the computed output to right
//     '_column_head_'  may indicate that I/O values are below
//
// *  String Media:  All Programs & Functions could have been built
// into sCal and skip the call to 'eval()' to interpret strings;
// however,  that would be a different process from allowing the
// user to modify or creat new programming in the x-display.
// 
// *  Finding Code:  Sub-menus are called by exactly the first 7-
// characters of the catagory name.  The specific code in the HEAD
// is placed roughly in the order of Menu appearance, but it may
// be easier to locate by using the text editor's 'Find' function.
// These 7-characters can 'Find' the code area: sub-menu selections
// will be below the 'found', and additional strings to execute
// them (if any) are in the block immediately above it.
//
// *  JS References:  Many excellent books are available on the
// topic, as well as tutorials and code examples on the Web.  Both
// Netscape and Microsoft have extensive (though not all-inclusive)
// Guides and References that can be downloaded.  sCal contains
// only a sub-set of JS language elements--mostly listed in the
// JavaScript examples Group.  Comments are provided, but there
// are never enough.
//
// *  Reliability: NO EXHAUSTIVE ERROR CHECKING HAS BEEN CONDUCTED!
// Some errors can be anticipated.  Conversion factors and procedure
// output should be checked before relying upon the results.  And,
// of course, the user is expected to know when a computation is
// applicable to the problem at hand. Tho some simple discussion
// and an example may be included in the string or an s}(script),
// there is no substitute for comprehensive knowledge and 
// experience.
//
// *  Philosophy:  sCal is not intended to compete with big, slick
// full-blown applications in any areas it touches.  It is intended
// to be highly portable (hence JS & HTML); use only one "small"
// file (both source & executable, with no supplemental image,
// sound, .ddl etc. files to be installed); handy for the rare use
// of a procedure or quick implementation of a special calculation
// not warranting development of a large program.  It will not have
// extensive help files, options, and error-checking.
// 
//    III.  BROWSER DETERMINATION - MENU POPULATION: A small set
// of variables and functions at the end of the HEAD, before the
// BODY, to provide settings for browser variable text size and
// default menu groups. sCal is set up to run properly with recent
// versions of Netscape, Mozilla, or Internet Explorer (trademarks
// of respective providers) in their default, out-of-the-box set-
// tings. If a user has made modifications, their impact on sCal is
// unpredictable.  If unsatisfactory, some CSS instructions can be
// added, or direct code modifications made.
//
//    BODY:  The running sCal calculator is divided in a 2x2 table. 
// The cell boundries are clearly commented in the source code
// and can be compared to the visible form.  HTML is in the order
// of appearance.  Brief operating instructions are given in the
// lowest 2 cells.  Experimentation and reading this source code
// are highly recommended.
//
// **************************************************************

// *********************************** I. CALCULATOR OPERATION FUNCTIONS

var x = "";    // Display: by loose typing, 'x' mostly a string, sometimes a number
               // Advantages & Disadvantages.  Big problem is use of '+' to add strings.
               // Often necessary to induce JavaScript to treat variable as a number by
               // dividing it by 1: i.e. +x adds x-string, +x/1 adds numeric value of x.
               // A stray '/1' is seen in many formulations to use less code than eval().
var m = "";       // stores Memory
var nFlag = "0";  // determines function of [n] keys
n = new Array(20);// stores variables used in programming, initialize as empty strings
 for (i=0; i<20; i++) {n[i]="";}
var temp = "";

function Ix() {x = document.sCal.IOx.value;}
           // Input synch to x-string.  Do since TextArea can be changed from keyboard
function Ox() {document.sCal.IOx.value = x;}  // Output x-string change to display

function xEval() {Ix(); Im()// --- MAIN Evaluation Routine, invoked by screen [ = ] click ---
 for (i=0; i<20; i++) {nI(i);}    
 var j = x.indexOf('^');     // check to see if there is an x^y function
 if (j > 0) {                // all to left of '^' is taken as base and all right as exponent
  if (x.indexOf('^',j+10) {alert("WARNING! Only 1 [^] allowed in expression! Math.pow(x,y) preferred.");}
  else {                     // likewise, entire x-value is used as function argument, not just last term
  document.sCal.IOx.value = Math.pow(eval(x.substring(0,j)),eval(x.substring(j+1)));}}
 else {                      // check to see if a program, update variables for keyboard entries
  if (x.indexOf('=')>-1) {   // Note: certain calls reserved for programs ('=' designated)
   temp=x; eval(x); x=temp; Ox();}              // original x not changed in a program 
  else {document.sCal.IOx.value = eval(x);} }   // end of nested if-else statements
 Ix(); Om(); On();}          

function xPlusEq(s) {Ix(); x += s; Ox();}   // --- DISPLAY x functions ---
function xMultEq(s) {xEval(); x *= s; Ox();}
function Clear() {x = ""; Ox();}            // Clearing x often necessary when switching functions.
function BkSpace() {Ix(); x = x.substring(0,x.length-1; Ox();}
function recip() {xEval(); x = 1/(x); Ox();}
function xEnd() {Ix()return x.substr(x.length-1,1);}  // allows last char. of x to be a Flag;
 // click display button, or key if cursor placed at end of x, for a control. {x[i] doesn't work}

function JSwork(s// --- determine what to do with incoming MENU (s) values from [JS] button ---
 {if (s.indexOf('n[1]')>-1)          //-if there is program (indicated by presence of n[1]),
  {x=""; Ox(); xPlusEq(s); xEval();// fill in array.  ERROR if x-display not cleared prior.
  else {xPlusEq(s);}  }
 
function Xwork(s)  // --- determine what to do with incoming MENU (s) values from [Do] button ---
 {if (isNaN(s))
  {if (s.indexOf('x')>-1)        //-if expression, s, is f(x), i.e.Method,
   {xEval(); x = eval(s); Ox();// figure x, & substiture in function 
  else {x += eval(s); Ox();}  }  //-if a Property or program, add 's' value
 else {xPlusEq(s);}   }          //-if numeric constant, append like JSwork
 
function DoRecip(s//--- does [1/d]: inverse [Do] eg. ft>m becomes m>ft. NOT ALWAYS SENSIBLE! ---
 {Ix(); temp=eval(s)if (s.indexOf('x')>-1) {x=x*x/tempelse {x=1/tempOx();}

function Im() {m = document.sCal.IOm.value;// --- MEMORY functions: (similar to Ix() & Ox())
function Om() {document.sCal.IOm.value = m;}
function XtoM()  {Ix(); Im(); m += x; Om(); x=""; Ox();// Memory click operations:
function MtoX()  {Ix(); Im(); x += m; Ox();}
function Mplus() {xEval()if (m=="") {m=0// --- note that Mplus can accumulate:
 if (isNaN(m&& m.charAt(0)=="/"){m+=x+"/"}// string of data values, triggered by starting '/'
 else {m=parseFloat(m)+parseFloat(x)}       //   & using '/' as delimiter between values,
 Om(); x=""; Ox();}                         // or as summation & storage of a single value.
function Mclear() {m = ""; Om();}           // - Use MtoX to view/edit the string of values.

function nI(k) {n[k= eval("document.sCal.n"+k+".value");// --- for n[.] DATA ARRAY ---
 // for consistency with Ix() & Im() this would have been named In, except its reserved
function On() {                  // function On(k) like Ox() & Om().
 document.sCal.n0.value = n[0];  // These are values of the text boxes
 document.sCal.n1.value = n[1];  // on the right cell of sCal.
 document.sCal.n2.value = n[2];  // {This is not ellegant code
 document.sCal.n3.value = n[3];  // but the prior form of n[k]=
 document.sCal.n4.value = n[4];  // eval("document.sCal.n"+k+".value")
 document.sCal.n5.value = n[5];  // in the 'input' nI form, but
 document.sCal.n6.value = n[6];  // contrary to Netscape documentation,
 document.sCal.n7.value = n[7];  // eval("document.sCal.n"+k+".value")
 document.sCal.n8.value = n[8];  // =n[k] for On, doesn't work.}
 document.sCal.n9.value = n[9];
 document.sCal.n10.value=n[10];
 document.sCal.n11.value=n[11];
 document.sCal.n12.value=n[12];
 document.sCal.n13.value=n[13];
 document.sCal.n14.value=n[14];
 document.sCal.n15.value=n[15];
 document.sCal.n16.value=n[16];
 document.sCal.n17.value=n[17];
 document.sCal.n18.value=n[18];
 document.sCal.n19.value=n[19];}
 
function setNflag1() {nFlag="1";}  // sets flag to insert 'n[k]' in x-display
function setNflag2() {nFlag="2";}  // sets flag to insert value of n[k] in x 
function nData(k) {                // similar to Memory functions
 if (nFlag=="0") {n[k= x; On();}
 if (nFlag=="1") {Ix(); x += "n["+k+"]"; Ox(); nFlag="0";}  // Nflag is reset to 0
 if (nFlag=="2") {Ix(); nI(k); x += n[k]; Ox(); nFlag="0";}}//     after each use.
function Nclear() {for (i=0; i<20; i++) {n[i"";On();// clears entire n-array
  // --- except when data is specifically intended to carry over, it is good practice
  //  to clear the n-data array (AND the x-display) when switching to a new function.
  
function Mr(val,place) {var d=Math.pow(10,place);   //--- MISC. UTILITY FUNCTIONS ---    
 return Math.round(d*val)/d;}                       //--- Output decimal places ---
function Fo(val) {var d=0if (val<100){            // format output to 3 +/- significant figures
 if (val<10){d=2else {d=1}} return Mr(val,d)}
function fact(q) {var j=q; for (i=q;i>1;i--) {j*=fact(j-1)} return j};// factorial, n!=1*2*3*...*n
      // note recursion: fact(q) calls itself, above.
var Pi =Math.PI; // Consideration has been given to streamlining all Math. fcn. calls by defining
                 // them in a cluster; eg. sin(a)=Math.sin(a*PI/180) {in degrees vs. radians}, etc.
                 // With the math intensity of sCal, there would be a savings in code size (and it
                 // has been done in the cases above), but it would not encourage good JS coding.
                 // Not a big matter of principle, tho. User could do it, looking like VB.script. 
 

/* ****************************** II. MENU GROUPS WITH STRINGS OF JS SOURCE CODE:

     All of sCal is user-programmable, of course.  But the following Menu-Value
   setups should be particularly useful to engineers & scientific professionals for
   adding new functions, often just because many formulae are too easily forgettable.
                    --- Follow working code closely. ---
 GROUP MENU options format = "('selected.text','selected.value')",
 "('','')", <-copy/paste to fill in new options in chosen group
 Watch length of .text to avoid overrun of cell width (obvious when border blows).
 Last option must end with ); close parentheses & semi-colon, to end array.
   >       < use EXACTLY 7-characters of group name .text & EXACT CASE!  */

var A234567_nA = new Array("('A23456789 sample NAME','COMPUTATION string')",
 "('x} . NAME','COMP')",
 "('x} . . .','')",     // copy this section to start a new catagory;
 "('x} . . .','')",     // paste it to an appropriate location in the code;
 "('x} . . .','')",     // fill in the blanks with desired name, comp;
 "('x} . . .','')",     // copy the top catagory name to the desired option select
 "('x} . . .','')",     // menu (top, right cell) to make available for use.
 "('x} . . .','')",
 "('x} . . .','')",     // adding a calculation to an existing catagory: simply
 "('x} . . .','')",     // add blank lines where needed.  Delete these comments.
 "('x} . . .','')",     // Note that final line ending with semi-colon = critical.
 "('x} . . .','')",
 "('x} . . .','')",     // There are better blanks (less editing required) at
 "('','')");            // Catagory 3: Special for User_01; User_02; User_03.


// *********************** Catagory 1: default selection of conversions*********
//
// Sources (numerous, some discrepancies, potential transcription errors:)
// ASHRAE, Handbook of Fundamentals, Subcommittee Bryan, Wm. L, et al, 1972;
// Engineering Manual, Perry, Robert H, 3rd. Ed, McGraw Hill, 1976;
// Engineers Manual, Hudson, 2nd Ed, Ralph G, Wiley & Sons, 1944;
// Handbook of Chemistry and Physics, 47th Ed, CRC, 1966-67;
// Timber Construction Manual, American Inst. of Timber Constr, 2nd Ed, 1974;

var General_nA = new Array("('General: convert x}. Pi .','Math.PI')",
 "('len. x}. inch > millimeter','x*25.4')",
 "('length x} . . feet > meter','x*0.3048')",
 "('length x} . . . feet > mile','x/5280')",
 "('len. x} . mile >kilometer','1.609344*x')",
 "('area x} . ft^2 > meter^2','0.092903*x')",
 "('area x} . . feet^2 > acre','x/43560')",
 "('area x} . acre >hectare','0.404686*x')",
 "('area x} . acre > mile^2','x/640')",
 "('vol. x} . . ft^3 > meter^3','0.0283168*x')",
 "('vol. x} . . . . ft^3 > gallon','7.4805*x')",
 "('vol. x} .yd^3 > meter^3','0.764555*x')",
 "('force . . . lb(f) > Newton','4.44822*x')",
 "('mass x} . . . lb.US > kg','0.45359*x')",
 "('x} . . .','')",
 "('n} Rect.-Polar Convert',R_PCon)"// code for this is is at Analytic Geometry
 "('x} . . .','')",
 "('temp. . . C deg > F deg','9*x/5+32')",
 "('temp. . . F deg > C deg','5*(x-32)/9')",
 "('temp. . . C deg > K deg','x-273.15')");

var Length__nA = new Array("('length x} . feet > meter','x*0.3048')",
 "('x} . . . inch > millimeter','x*25.4')",
 "('x} . . . . . . yard > meter','x*0.9144')",
 "('x} . . .ft(us) > ft(survey)','x*0.9999980315')",
 "('x} . . . . . . feet > link','x/0.66')",
 "('x} . . . . . . feet > rod','x/16.5')",
 "('x} . . . . . . feet > chain','x/66')",
 "('x} . . . . . . feet > inch','x*12')",
 "('x} . . . . . . feet > hand','x*3')",
 "('x} . . . . . . feet > cubit','x/1.5')",
 "('x} . . . . . . feet > yard','x/3')",
 "('x} . . . . . feet > fathom','x/6')",
 "('x} . . . . . feet > furlong','x/660')",
 "('x} . . . . . . feet > cable','x/720')",
 "('x} . . . . . . feet > mile','x/5280')",
 "('x} feet > mile(int.naut.)','x/6076.115485')",
 "('x} . . . mile > kilometer','x*1.609344')",
 "('x} mile > league(stat.)','x/3')",
 "('x} mile>league(intnat)','x/3.45')",
 "('x} . mile > astrom.unit','x/92955763.342')",
 "('x} . . . . . mile > parsec','x/1.917377515e13')",
 "('x} . . . mile > light year','x/5.87851323e12')",
 "('x} . . .','')",
 "('x} . . inch > pica(print)','x*6')",
 "('x} . .inch > point(print)','x*72')",
 "('x} . . .','')",
 "('x} . . . meter > micron','x*1e6')",
 "('x} . meter > angstrom','x*1e10')");
  
var Area_co_nA = new Array("('Area conv.x} f^2 >m^2','x*0.092903')",
 "('x} . . . . . feet^2 > inch^2','x*144')",
 "('x} . . . . . . inch^2 > cm^2','x*6.4516')",
 "('x} . . . . .feet^2 > yard^2','x/9')",
 "('x} . . .yard^2 > meter^2','x*0.83612736')",
 "('x} . . . . . . . feet^2 > acre','x/43560')",
 "('x} . . . . . acre > hectare','x*0.40468564')",
 "('x} . . . . . .mile^2 > km^2','x*2.589988')",
 "('x} . . . . . . feet^2 > rood','x/10890')",
 "('x}acre>sq.mi.(section)','x/640')",
 "('x} . . mile^2 > township','x/36')"
 "('x} . . .','')",
 "('x} circular inch > sq.in.','x*Math.PI/4')",
 "('x} circular mm > sq.mm','x*Math.PI/4')",
 "('x} circular in. > circ.mil','x*1000000')",
 "('x} circular in. > circ.mm','x*645.16')",
 "('x} . . .','')",
 "('x} . . .','')",
 "('x} . . .','')");
 
var Volume__nA = new Array("('Vol. conv. x} ft^3 > m^3','x*0.0283168')",
 "('x} . . . . . feet^3 > inch^3','x*1728')",
 "('x} . . . . . .inch^3 > cm^3','x*16.387064')",
 "('x} . . . . .feet^3 > yard^3','x/27')",
 "('x} . . .yard^3 > meter^3','x*0.764555')",
 "('x} . . . .acre.ft > meter^3','x*1233.48')",
 "('x} . . .','')",
 "('x} gallon(US)>gal(Imp.)','x*0.83261')",
 "('x} fl.oz(us) > teaspoon','x*6')",
 "('x} fl.oz(us)>tablespoon','x*2')",
 "('x} . fl.oz(us) > fl.oz(Brit)','x*1.04')",
 "('x} .fluid oz(us) > inch^3','x*1.8')",
 "('x} . .fluid oz(us) > cm^3','x*29.573')",
 "('x} fluid ounce(us) >cup','x/8')",
 "('x} . . .fl.oz(us) > pint(us)','x/16')",
 "('x} fl.oz(us) >quart(fl.us)','x/32')",
 "('x} . . . . . . fl.oz(us) > liter','x/33.8146282')",
 "('x} quart(us)liquid > dry','x*0.8594')",
 "('x} quart(us.liq) >gallon','x/4')",
 "('x} . . . . . feet^3 > gallon','x*7.4805')",
 "('x} ft^3>bushel(us.dry)','x*0.80356')",
 "('x} feet^3 > bbl(us.liq)','x*0.237483')",
 "('x} feet^3 > bbl(us.oil)','x*0.17811')",
 "('x} feet^3 > bbl(us.dry)','x*0.2449')",
 "('x} ft^3>ton(us.shipng)','x/40')",
 "('x} ton(register)>m^3','x*2.8317')",
 "('x} . . .','')",
 "('x} . . feet^3 > board.ft','x*12')",
 "('x} . ft^3 > cord(wood)','x/128')");
 
var Time_Ve_nA = new Array("('Time_Velocity x} hr > s','x*3600')",
 "('x} . . . day > second','x*86400')",
 "('x} . sec.> nanosecond','x*1e9')",
 "('x}sec(sidereal)>s(solr)','x*0.9972695')",
 "('x} day > day(sidereal)','x*1.0027379')",
 "('x} year > yr.(sidereal)','x*0.999298')",
 "('x} year > day(actual)','x*365.24')",
 "('','')",
 "('x} velocity: ft/s > mi/hr','x*0.68181818')",
 "('x} . meter/sec > km/hr','x*3.6')",
 "('x} . . . . . . mi/hr > km/hr','x*1.609344')",
 "('x} . . . . . . mi/hr > knot','x*0.86898')",
 "('x} . . . mi/hr > Mach no.','x/741.5444')",
 "('x} C(light speed) >m/s','x*2.99792458e8')",
 "('','')",
 "('','')");

var Mass_Fo_nA = new Array("('Mass_Force x} lb > kg','x/2.204634')",
 "('x} lb(pound.av)>lb.troy','x*1.215 //avoirdupois is common used here')",
 "('x} . . . . lb > oz(avoir.)','x*16')",
 "('x} . . . . lb > oz (troy)','x*14.58')",
 "('x} . . lb > carat(metric)','x*2267.95')",
 "('x} gram > carat(metric)','x*5')",
 "('x}      gram > grain','x*15.432')",
 "('','')",
 "('x}pound(lb.mass)>slug','x/32.174')",
 "('x} . . . . lb > grains','x*7000')",
 "('x} . . lb > stone(Brit)','x/14')",
 "('x} . . . . . lb > ton','x/2000')",
 "('x} . . . . . lb > ton(metric)','x/2204.634')",
 "('x} . . . . . lb > ton(long)','x/2240')",
 "('x} . . .','')",
 "('s} DEFINITION F=MA','if a=g~9.8m/sec^2, kg * g = N (Newton)')",
 "('x} . . .','')",
 "('x} . kg(f) > Newton','x*9.80665')",
 "('x} . . kg.m/sec > N','x*1.0')",
 "('x} . . . . . . . J/m > N','x*1.0')",
 "('x} . . . . . .dyne > N','x/10000')",
 "('x} . . . . gram(f) > dyne','x*980.665')",
 "('x} . . . . . . lb(f) > N','x*4.44822')",
 "('x} . . . . . . lb(f) > kip','x/1000')",
 "('x} . . . . . lb(f) > poundal','x*32.174')",
 "('x} . . .','')",
 "('x} . . .','')");

var Pressur_nA = new Array("('Pressure x} p.s.i. > Pa','x*6894.757')",
 "('x} . . N/sq.m > Pascal','x*1.0 // definition')",
 "('x} . . dyne/sq.cm > Pa','x*0.1')",
 "('x} . . . . . lb(f)/sq.ft > Pa','x*47.88')",
 "('x} . tons/s.f. > kg/cm^2','x*0.9765')",
 "('x} . . . . kg(f)/sq.m > Pa','x*9.80665')",
 "('x} Newton/cm^2 > Pa','x*10000')",
 "('x} . . . . . . . cm Hg > Pa','x*1333.224')",
 "('x} . . . in Hg(32 F) > Pa','x*3386.38')",
 "('x} . . . in Hg(60 F) > Pa','x*3376.85')",
 "('x} . . .','')",
 "('x} . atmosphere > Pa','x*101325')",
 "('x} . . . . atm(std) > p.s.i.','x*14.69595')",
 "('x} . . . . . atm(std) > bar','x*1.01325')",
 "('x} . . . . . bars > Pascal','x*100000')",
 "('x} . . .atm(std) > in Hg','x*29.92')",
 "('x} . . atm(std) > ft.water','x*33.899')",
 "('x} . . .','')",
 "('x} . .','')");
 
var Density_nA = new Array("('Density x} p/cf >kg/m^3','x*16.02')",
 "('x} . lb/gal(us) > kg/cu.m','x*119.83')",
 "('x} . . g/cu.cm > kg/cu.m','x*1000')",
 "('x} milligram/liter > kg/l','x*1e-6')",
 "('x} megag./cu.m. > kg/l','x*1.0')",
 "('x} . oz/gal(us)>kg/c.m','x*7.489')",
 "('x} oz/gal(us)>oz/g(uk)','x*1.2')",
 "('x} . ton/c.y. > kg/liter','x*1.18655')",
 "('x} g/cu.cm > spec.grav','x*1.0')",
 "('x} . . g/cc = kg/l > s.g.','x*1.0')",
 "('x} . . . . . . lb/cu.ft > s.g.','x/62.428')",
 "('x} . . . . . . lb/cu.in > s.g.','x/0.036127')",
 "('x} . . . . . . . lb/gal > s.g.','x/8.345')",
 "('x} . . .','')",
 "('s} TYP. Values of S.G.','see Materials charts in this catagory.')",
 "('s} . . .','')",
 "('s} . . .','')",
 "('s} . . .','')");

var Energy__nA = new Array("('Energy_or work s} Def.','Energy=work ~F*dist')",
 "('x} . . Watt.sec > Joule','x*1.0 //definition')",
 "('x} . . . . Watt.hr > Joule','x*3600')",
 "('x} . . . kWatt.hr > Joule','x*3600000')",
 "('x} . . . . Btu(mean) > J','x*1054.35')",
 "('x} . . . . . . Btu(ISO) > J','x*1055.06')",
 "('x} . . . . . . . . . ft.lb(f) > J','x*1.355818')",
 "('x} . . . . . . . . . kg.m > J','x*9.80665')",
 "('x} . . . . . . . . . . kCal > J','x*4186.75')",
 "('x} . . . . . . . . . therm > J','x*105506000')",
 "('x} . . . . . therm(us) > J','x*105480400')",
 "('x} tonsTNT equiv >J','x*4200000000')",
 "('x} horsepower.hr >J','x*2.6845e6')",
 "('x} . . metric HP.hr > J','x*2.648e6')",
 "('x} liter.atmosphere>J','x*101.33')",
 "('x} . . . . . . dyne.cm > J','x/10000000')",
 "('x} . . . . dyne.cm > erg','x*1.0 //definition')",
 "('x} . . .','')",
 "('x} . .','')");
 
var Power_r_nA = new Array("('Power_rate of Work s}','Power ~energy/time')",
 "('x} . . . . . Watt > Btu/hr','x*3.414426')",
 "('x} . . . kw > Btu/sec','x*0.9478')",
 "('x} . . . kw > poncelet','x*1.02')",
 "('x} . . . kw > kg.m/sec','x*102')",
 "('x} . . . Watt > cal/sec','x*0.23885')",
 "('x}W>candle pow(sp.)','x*53.2481363')",
 "('x} . . . . . W > erg/sec','x*10000000')",
 "('x} . . . W > ft.lb(f)/sec','x*0.737562')",
 "('x} W > HP (550ft.lb/s)','x/745.7')",
 "('x} . . . W > HP (metric)','x/735.5')",
 "('x} . . . . . . . W > lumen','x*668.45')",
 "('x} W > tons.refrigerat.','x/3516.9')",
 "('x} tons.refrig >BTU.hr','x*1200')",
 "('x} . . .','')",
 "('x} . . .','')",
 "('','')");
 
var HtRes="R =resistance to heat flow (reciprocal of conductivity). R values are added to obtain ";
  HtRes +="reciprocal of overall heat transmission of a building surface, U. eg. for a frame wall: ";
  HtRes +="Outside surf.15mph wind R~0.17 deg.F/Btu/hr/sf; wood siding, 1/2in.w/laps R~0.81; ";
  HtRes +="Sheathing, 1/2in. asph.impreg.board R~1.32; Insulation, 4in.fiberglass R~11; Gypsum wall";
  HtRes +="board R~0.45; Inside surf. still air R~0.68; ->Total R=14.43 =1/U -> U=0.0697Btu/hr.sf.F";
  HtRes +=" adjust for framing:2x4 @ 16in.cts ->U*1.08 =0.075.  Heating capacity needed is then ";
  HtRes +="computed from sq.ft of walls, adj. windows, doors, ceiling, etc. Apply to design temp.";  

var Heat_Te_nA = new Array("('Heat_Temperature: s}','meas. of atomic kinetic energy')",
 "('x}. . . C deg > F deg','9*x/5+32')",
 "('x}. . . F deg > C deg','5*(x-32)/9')",
 "('x}. . . C deg > K deg','x-273.15')",
 "('x} . . .F deg > R deg','x-458.57')",
 "('x} . . .','')",
 "('x} . BTU/lb > J/kg','x*2326')",
 "('x} . . cal/g > J/kg','x*4186')",
 "('x} . . . C/m>W/m.C','x*1.0')",
 "('x} . . .','')",
 "('s} __HEAT FLOW__','rate of Heat per area')",
 "('x} Watt/cm^2 >Btu/hr.sf','x*3170')",
 "('x} watt/cm^2 >Btu/dy.sf','x*76081')",
 "('x} w/cm^2 >cal/hr.cm^2','x*860')",
 "('x} w/cm^2 > cal/s.cm^2','x*0.2388')",
 "('s} _CONDUCTANCE_','=heat flow per deg.F or deg.C temperature gradient')",
 "('x} w/cm^2.C>Btu/hr.sf.F','x*1761')",
 "('x} w/sm.C>cal/hr.sm.C','x*860')",
 "('x} w/smC>cal/s.sm.C','x*0.2388')",
 "('x}Btu/hr.sf.F>W/s.sm.C','x*5.6784')",
 "('x}kcal/hr.sm.C>w/sm.C','x*1.163')",
 "('s}_CONDUCTIVITY, k','conductance through a thickness of material')",
 "('x} w/scm(cm/C)>Btu/h..','x*57.79 // watt/cm^2(cm/C)>Btu/hr.sf(ft/F)')",
 "('x} w/sm(cm/C)>cal/h...','x*860 // watt/sm(cm/C)>cal/h.sm(cm/C)')",
 "('x} Btu/s.sf(in/F)>cal..','x*1.2405 // Btu/s.sf(in/F)>cal/s.cm^2(cm/C)')",
 "('x}Btu/hr.sf.(in/F)>w/m.C','x*0.1442')",
 "('s}_RESISTIVITY,1/k_',HtRes)",
 "('x} . . .','')",
 "('x} . . .','')",
 "('','')");

var Light_R_nA = new Array("('Light_Rad. lux>lum./sm','x*1.0')",
 "('x} . candle pow.>lumen','x*12.556')",
 "('x} . . . . lumen > watt','0.001496')",
 "('x} . . . . lux > ft.candle','x*0.0929')",
 "('x} . ft.candle>lumen/s.f','x*0.0929')",
 "('x} . . .','')",
 "('x} candela/s.in>ft.lam.','x*452.389 //c./sq.inch>foot.lambert')",
 "('x} candela/s.in>c./s.m','x*1550')",
 "('x} . . .','')",
 "('x}rayleigh>ph./sm.sec','1.0E10 //photon emission/sq.m.Second')",
 "('x} roentgen>coul./kg','x*2.57976E-4')",
 "('x} . . dose rad > J/kg','x/100')",
 "('x} . . Rutherford > Bq','x*1000000 // disintegrations/second')",
 "('x} . . curie >disinteg/s','x*3.7e10')",
 "('x} . . .','')",
 "('','')");
   
var DMStoDeg="var dg=(/*Deg*/ ); var mn=(/*min*/ ); var sc=(/*sec*/ ); /*CLICK[=]*/ ";
  DMStoDeg +="m=dg + mn/60 + sc/3600; ";
var AZtoBEAR="var Az=(/*Azimuth 0-deg @ N, rotate to E.(right)*/ ); /*CLICK[=]*/ ";
  AZtoBEAR +="var Quad=Math.floor(Az/90); while (Quad>=4) {Quad-=4} var d=Az%90; ";
  AZtoBEAR +="if (Quad==0||Quad==3) {m='N';} else {m='S';} if (Quad==1 || Quad==3) ";
  AZtoBEAR +="{d=90-d} m+=Mr(d,4); if (Quad>1) {m+='W'} else {m+='E'}";
 
var Angular_nA = new Array("('Angular x} . . deg > rad','x*Math.PI/180')",
 "('x} . . . . grad > degrees','x*360/400')"