# ERDAS IMAGINE Q&A

ERDAS IMAGINE, the world’s leading geospatial data authoring system, supplies tools for all your Remote Sensing and Photogrammetry needs.
Showing results for
Do you mean

# Calculator Example EML

by on ‎10-02-2015 09:11 AM - edited on ‎03-25-2016 03:46 AM by Anonymous (257 Views)

• ,
• ### ERDAS IMAGINE

component calculator {

frame calc_frame;

frame calc_frame {

variable powr;

variable temp;

variable deci;

variable dotk;

variable opr1;

variable opr2;

variable sub;

variable mul;

variable div;

variable pow;

variable cls;

variable pi;

variable degs;

variable mem;

variable input_val;

textnumber oprt_one;

button one;

button two;

button three;

button four;

button five;

button six;

button seven;

button eight;

button nine;

button zero;

button decimal;

button sign;

button inv;

button sin;

button cos;

button tan;

button asin;

button acos;

button atan;

button sqrt;

button square;

button xpowy;

button natural;

button clear;

button memry;

button recall;

button equal;

button stopit;

minimumsize 10, 8;

title "Calculator";

fileclose "Close|Ctrl<Key>D|Ctl+D"

}

helpstring "Calculator, ver. 8.3" {}

}

textnumber oprt_one {

geometry 10,5,303,30;

rangespec -1e+100, nolimit;

delta 0.000000000000001;

format "5.7";

}

button one {

title "1";

info "One";

geometry 165,40,30,30;

background "#999999";

on mousedown {

if (\$CLS == 1) {

set oprt_one = 0.0;

}

if (\$Deci == 0) {

set powr = \$oprt_one*10.0;

set oprt_one = 1.0 + \$powr;

set CLS = 0.0;

}

elsif (\$Deci == 1) {

set powr = 1.0 / ( 10.0^(\$dotk + 1));

set oprt_one = \$powr + \$oprt_one;

set dotk = \$dotk + 1.0;

set CLS = 0.0;

}

}

}

button two {

title "2";

info "Two";

geometry 205,40,30,30;

background "#999999";

on mousedown {

if (\$CLS == 1) {

set oprt_one = 0.0;

}

if (\$Deci == 0) {

set powr = \$oprt_one*10.0;

set oprt_one = 2.0 + \$powr;

set CLS = 0.0;

}

elsif (\$Deci == 1) {

set powr = 2.0 / ( 10.0^(\$dotk + 1));

set oprt_one = \$powr + \$oprt_one;

set dotk = \$dotk + 1.0;

set CLS = 0.0;

}

}

}

button three {

title "3";

info "Three";

geometry 245,40,30,30;

background "#999999";

on mousedown {

if (\$CLS == 1) {

set oprt_one = 0.0;

}

if (\$Deci == 0) {

set powr = \$oprt_one*10.0;

set oprt_one = 3.0 + \$powr;

set CLS = 0.0;

}

elsif (\$Deci == 1) {

set powr = 3.0 / ( 10.0^(\$dotk + 1));

set oprt_one = \$powr + \$oprt_one;

set dotk = \$dotk + 1.0;

set CLS = 0.0;

}

}

}

button four {

title "4";

info "Four";

geometry 165,80,30,30;

background "#999999";

on mousedown {

if (\$CLS == 1) {

set oprt_one = 0.0;

}

if (\$Deci == 0) {

set powr = \$oprt_one*10.0;

set oprt_one = 4.0 + \$powr;

set CLS = 0.0;

}

elsif (\$Deci == 1) {

set powr = 4.0 / ( 10.0^(\$dotk + 1));

set oprt_one = \$powr + \$oprt_one;

set dotk = \$dotk + 1.0;

set CLS = 0.0;

}

}

}

button five {

title "5";

info "Five";

geometry 205,80,30,30;

background "#999999";

on mousedown {

if (\$CLS == 1) {

set oprt_one = 0.0;

}

if (\$Deci == 0) {

set powr = \$oprt_one*10.0;

set oprt_one = 5.0 + \$powr;

set CLS = 0.0;

}

elsif (\$Deci == 1) {

set powr = 5.0 / ( 10.0^(\$dotk + 1));

set oprt_one = \$powr + \$oprt_one;

set dotk = \$dotk + 1.0;

set CLS = 0.0;

}

}

}

button six {

title "6";

info "Six";

geometry 245,80,30,30;

background "#999999";

on mousedown {

if (\$CLS == 1) {

set oprt_one = 0.0;

}

if (\$Deci == 0) {

set powr = \$oprt_one*10.0;

set oprt_one = 6.0 + \$powr;

set CLS = 0.0;

}

elsif (\$Deci == 1) {

set powr = 6.0 / ( 10.0^(\$dotk + 1));

set oprt_one = \$powr + \$oprt_one;

set dotk = \$dotk + 1.0;

set CLS =0.0;

}

}

}

button seven {

title "7";

info "Seven";

geometry 165,120,30,30;

background "#999999";

on mousedown {

if (\$CLS == 1) {

set oprt_one = 0.0;

}

if (\$Deci == 0) {

set powr = \$oprt_one*10.0;

set oprt_one = 7.0 + \$powr;

set CLS = 0.0;

}

elsif (\$Deci == 1) {

set powr = 7.0 / ( 10.0^(\$dotk + 1));

set oprt_one = \$powr + \$oprt_one;

set dotk = \$dotk + 1.0;

set CLS = 0.0;

}

}

}

button eight {

title "8";

info "Eight";

geometry 205,120,30,30;

background "#999999";

on mousedown {

if (\$CLS == 1) {

set oprt_one = 0.0;

}

if (\$Deci == 0) {

set powr = \$oprt_one*10.0;

set oprt_one = 8.0 + \$powr;

set CLS = 0.0;

}

elsif (\$Deci == 1) {

set powr = 8.0 / ( 10.0^(\$dotk + 1));

set oprt_one = \$powr + \$oprt_one;

set dotk = \$dotk + 1.0;

set CLS = 0.0;

}

}

}

button nine {

title "9";

info "Nine";

geometry 245,120,30,30;

background "#999999";

on mousedown {

if (\$CLS == 1) {

set oprt_one = 0.0;

}

if (\$Deci == 0) {

set powr = \$oprt_one*10.0;

set oprt_one = 9.0 + \$powr;

set CLS = 0.0;

}

elsif (\$Deci == 1) {

set powr = 9.0 / ( 10.0^(\$dotk + 1));

set oprt_one = \$powr + \$oprt_one;

set dotk = \$dotk + 1.0;

set CLS = 0.0;

}

}

}

button zero {

title "0";

info "Zero";

geometry 205,160,30,30;

background "#999999";

on mousedown {

if (\$CLS == 1) {

set oprt_one = 0.0;

}

if (\$Deci == 0) {

set powr = \$oprt_one*10.0;

set oprt_one = 0.0 + \$powr;

set CLS = 0.0;

}

elsif (\$Deci == 1) {

set powr = 0.0 / ( 10.0^(\$dotk + 1));

set oprt_one = \$powr + \$oprt_one;

set dotk = \$dotk + 1.0;

set CLS = 0.0;

}

}

}

button decimal {

title ".";

info "Decimal";

geometry 245,160,30,30;

background "#999999";

on mousedown {

set Deci = 1;

}

}

button sign {

title "+/-";

info "Sign";

geometry 165,160,30,30;

background "#999999";

on mousedown {

set oprt_one = -1.0*\$oprt_one;

set CLS = 1;

}

}

title "+";

geometry 285,40,30,30;

background "#999999";

on mousedown {

calcit ();

set OPR1 = \$oprt_one;

}

}

button subtraction {

title "-";

info "Subtraction";

geometry 285,80,30,30;

background "#999999";

on mousedown {

calcit ();

set SUB = 1;

set OPR1 = \$oprt_one;

}

}

button multiplication {

title "x";

info "Multiplication";

geometry 285,120,30,30;

background "#999999";

on mousedown {

calcit ();

set MUL = 1;

set OPR1 = \$oprt_one;

}

}

button division {

title "/";

info "Division";

geometry 285,160,30,30;

background "#999999";

on mousedown {

calcit ();

set DIV = 1;

set OPR1 = \$oprt_one;

}

}

button inv {

title "1/x";

info "Power";

geometry 10,160,30,30;

background "#999999";

on mousedown {

calcit ();

set input_val = \$oprt_one;

set oprt_one = 1.0 / \$oprt_one;

echo "1 /" \$input_val "=" \$oprt_one;

set CLS = 1;

}

}

button sin {

title "SIN";

info "Sine";

geometry 50,80,45,30;

background "#999999";

on mousedown {

calcit ();

set input_val = \$oprt_one;

if (\$radeg == "0") set degs = (\$PI/180.0)*\$oprt_one;

if (\$radeg == "1") set degs = \$oprt_one;

set oprt_one = sin(\$degs);

echo "SIN (" \$input_val ") =" \$oprt_one;

set CLS = 1;

}

}

button cos {

title "COS";

info "Cosine";

geometry 50,120,45,30;

background "#999999";

on mousedown {

calcit ();

set input_val = \$oprt_one;

if (\$radeg == "0") set degs = (\$PI/180.0)*\$oprt_one;

if (\$radeg == "1") set degs = \$oprt_one;

set oprt_one = cos(\$degs);

echo "COS (" \$input_val ") =" \$oprt_one;

set CLS = 1;

}

}

button tan {

title "TAN";

info "Tangent";

geometry 50,160,45,30;

background "#999999";

on mousedown {

calcit ();

set input_val = \$oprt_one;

if (\$radeg == "0") set degs = (\$PI/180.0)*\$oprt_one;

if (\$radeg == "1") set degs = \$oprt_one;

set oprt_one = tan(\$degs);

echo "TAN (" \$input_val ") =" \$oprt_one;

set CLS = 1;

}

}

button asin {

title "ASIN";

info "Arcsine";

geometry 105,80,45,30;

background "#999999";

on mousedown {

calcit ();

set input_val = \$oprt_one;

set degs = asin(\$oprt_one);

if (\$radeg == "0") set oprt_one = (180.0/\$PI)*\$degs;

if (\$radeg == "1") set oprt_one = \$degs;

echo "ASIN (" \$input_val ") =" \$oprt_one;

set CLS = 1;

}

}

button acos {

title "ACOS";

info "Arccosine";

geometry 105,120,45,30;

background "#999999";

on mousedown {

calcit ();

set input_val = \$oprt_one;

set degs = acos(\$oprt_one);

if (\$radeg == "0") set oprt_one = (180.0/\$PI)*\$degs;

if (\$radeg == "1") set oprt_one = \$degs;

echo "ACOS (" \$input_val ") =" \$oprt_one;

set CLS = 1;

}

}

button atan {

title "ATAN";

info "Tangent";

geometry 105,160,45,30;

background "#999999";

on mousedown {

calcit ();

set input_val = \$oprt_one;

set degs = atan(\$oprt_one);

if (\$radeg == "0") set oprt_one = (180.0/\$PI)*\$degs;

if (\$radeg == "1") set oprt_one = \$degs;

set CLS = 1;

echo "ATAN (" \$input_val ") =" \$oprt_one;

}

}

button sqrt {

title "SQRT";

info "Tangent";

geometry 50,40,45,30;

background "#999999";

on mousedown {

calcit ();

set input_val = \$oprt_one;

set oprt_one = \$oprt_one^0.5;

echo "SQRT (" \$input_val ") =" \$oprt_one;

set CLS = 1;

}

}

button square {

title "x^2";

info "Square";

geometry 10,40,30,30;

background "#999999";

on mousedown {

calcit ();

set input_val = \$oprt_one;

set temp = (\$oprt_one)^2.0;

if (\$temp > 10e30) {

set temp = 0.0;

}

set oprt_one = \$temp;

echo \$input_val "^ 2 =" \$oprt_one;

set CLS = 1;

}

}

button xpowy {

title "x^y";

info "X power Y";

geometry 10,120,30,30;

background "#999999";

on mousedown {

calcit ();

set POW = 1;

set OPR1 = \$oprt_one;

set powr = 0.0;

set Deci = 0.0;

set dotk = 0.0;

set CLS = 1;

}

}

button natural {

title "e^x";

info "Natural";

geometry 10,80,30,30;

background "#999999";

on mousedown {

calcit ();

set input_val = \$oprt_one;

set temp = 2.718281828^\$oprt_one;

if (\$temp > 3814279.10) {

set temp = 0.0;

}

set oprt_one = \$temp;

echo "e ^" \$input_val "=" \$oprt_one;

set CLS = 1;

}

}

button pibutton {

title "PI";

info "Pi";

geometry 112,40,31,30;

background "#999999";

on mousedown {

set oprt_one = 3.141592654;

set CLS = 1;

}

}

button clear {

title "CLEAR";

info "Pi";

geometry 330,120,60,30;

background "#999999";

on mousedown {

set oprt_one = 0.0;

set Deci = 0.0;

set dotk = 0.0;

set powr = 0;

set SUB = 0;

set MUL = 0;

set DIV = 0;

set POW = 0;

}

}

button memry {

title "STORE";

info "Memory";

geometry 330,40,60,30;

background "#999999";

on mousedown {

calcit ();

set MEM = \$oprt_one;

set CLS = 1;

}

}

button recall {

title "RECALL";

info "Memory recall";

geometry 330,80,60,30;

background "#999999";

on mousedown {

set oprt_one = \$MEM;

set MEM = 0.0;

set CLS = 1;

}

}

button equal {

title "=";

geometry 330,160,60,30;

background "#999999";

on mousedown {

calcit();

}

}

geometry 330,5,60,30;

background "#999999";

names { "0","1" };

}

on framedisplay   {

set PI = 3.141592654;

set oprt_one = 0;

set powr = 0;

set Deci = 0;

set dotk = 0;

set SUB = 0;

set MUL = 0;

set DIV = 0;

set POW = 0;

set CLS = 0;

set MEM = 0;

}

on calcit {

set OPR2 = \$oprt_one;

set oprt_one = \$OPR1 + \$OPR2;

echo \$OPR1 "+" \$OPR2 "=" \$oprt_one;

}

else if (\$SUB == 1) {

set OPR2 = \$oprt_one;

set oprt_one = \$OPR1 - \$OPR2;

echo \$OPR1 "-" \$OPR2 "=" \$oprt_one;

}

else if (\$MUL == 1) {

set OPR2 = \$oprt_one;

set oprt_one = \$OPR1 * \$OPR2;

echo \$OPR1 "*" \$OPR2 "=" \$oprt_one;

}

else if (\$DIV == 1) {

set OPR2 = \$oprt_one;

if (\$OPR2 != 0) {

set oprt_one = \$OPR1 / \$OPR2;

echo \$OPR1 "/" \$OPR2 "=" \$oprt_one;

}

}

else if (\$POW == 1) {

set OPR2 = \$oprt_one;

set oprt_one = (\$OPR1)^(\$OPR2);

echo \$OPR1 "^" \$OPR2 "=" \$oprt_one;

}

set powr = 0;

set Deci = 0;

set dotk = 0;

set SUB = 0;

set MUL = 0;

set DIV = 0;

set POW = 0;

set CLS = 1;

}

}

on startup display calc_frame;

}

Contributors