.DATE .Run Name: CALC By: Rob Haeuser ©1994-2012 Ver. 11.000 *Function: Calculator runs stand-alone, @LNKed, or @CALLed as a subroutine. * The Total and Ticker are returned to the CALLing or LNKing run. *=============================================================================== :L1=13,3=30,5=102,7=104,10=121,15=126,18=129,20=130,25=135,28=141,30=146,31=147 :L32=148,33=149,34=150,35=151,36=152,37=153,38=154,39=155,40=156,41=157,45=163 :L46=164,47=165,48=166,50=171,55=180,56=185,58=186,60=187,62=188,64=189,66=190 :L68=191,70=192,72=193,74=194,76=195,78=196,80=197,82=198,84=199,86=200,88=201 :L90=202,92=203,94=204,96=205,98=206,100=213,103=216,105=217,108=220,110=222 :L115=229,120=233,125=240,130=250,151=258,152=259,153=260,154=261,155=262 :L156=263,160=264,185=269,188=275,198=411,199=417 @0001:() RAR 0199 RER,EDRW$,2 1 . @ IF DLINE$ > 0 IF DRW$ > 0 RNM -1 CHG
i6 DLINE$ ;. @ IF WS$ > 0 . ;GTO 0198 . <- can only run on a Workstation @ LDV h13='000000/cdcdcd',h13='000000/00ccee',\ h13='ffffff/1111bb',h13='ffffff/777777',\ i2,h1,i3,a15,i4=6,i4,i4=94,h1=+,\ s80,h1,s40='Memory is currently empty',a15,i13,\ i13,h1=+,i1,a15,a15,a15 . @ IF RUN$ = CALC CHG INPUT$ a15 . ;LDV =,a15=,='' . @ IF = '' LDV =0 ;LDV,r ,= . @ BRK SCN ,,,,, CHG /2 INC,2 . . CALC Ticker * * Current Total Operand New Total In Memory *===============.=.===============.=.===============.===============. @ IF = 0 LDV =5 GTO 0003 ;LDV =6 . @0003:BRK RNM -2 LN+,-2,,88 . @ FON,t,'Courier New',22,bdp . @ WIN,,5,,17,31,,ho ' GURU Calculator' i6 . @ MNU,, MENUBAR,"&Quit",,L:0199 MENUBAR,"&Ticker",,L:0130 MENUBAR,"G&uru",,L:0185 MENUBAR,"&Help",,L:0188 @ TXT,"",,2,4,1,1,,3b i6 TIP," (p) ", . <- memory flag @ EDT,"",,2,9,1,15,,3r i6 . <- input area @ TXT,"",,2,28,1,1,,3b i6 . <- operation @ BTN,,4,3,2,4 'C' i6 . @ TIP," Clear the totals (this does NOT clear Memory) ", . @ BTN,,4,9,2,5 '7' <7>i6 BTN,,4,14,2,5 '8' <8>i6 . @ BTN,,4,19,2,5 '9' <9>i6 BTN,,4,26,2,4 '+' i6 . @ BTN,,6,3,2,4 'CE' i6 . @ TIP," Clear the current entry only ", . @ BTN,,6,9,2,5 '4' <4>i6 BTN,,6,14,2,5 '5' <5>i6 . @ BTN,,6,19,2,5 '6' <6>i6 BTN,,6,26,2,4 '-' i6 . @ BTN,,8,3,2,4 'MC' i6 . @ TIP," Clear Memory ", . @ BTN,,8,9,2,5 '1' <1>i6 BTN,,8,14,2,5 '2' <2>i6 . @ BTN,,8,19,2,5 '3' <3>i6 BTN,,8,26,2,4 '*' i6 . @ BTN,,10,3,2,4 'MR' i6 . @ TIP," Recall the value in Memory ", . @ BTN,,10,9,2,5 '0' <0>i6 BTN,,10,14,2,5 '.'

i6 . @ BTN,,10,19,2,5 '=' i6 BTN,,10,26,2,4 '/' i6 . @ BTN,,12,3,2,4 'M+' i6 . @ TIP," Add the current total to Memory ", . @ BTN,,13,9,1,3 'Ab' i6 . @ TIP," Absolute value or Magnitude ", . @ BTN,,13,12,1,3 'Ac' i6 . @ TIP," Arc Cosine in Radians ", . @ BTN,,13,15,1,3 'As' i6 . @ TIP," Arc Sine in Radians ", . @ BTN,,13,18,1,3 'At' i6 . @ TIP," Arc Tangent in Radians ", . @ BTN,,13,21,1,3 'Cr' i6 . @ TIP," Cube Root ", . @ BTN,,13,24,1,3 'Cs' i6 . @ TIP," Cosine in Radians ", . @ BTN,,13,27,1,3 'Ct' i6 . @ TIP," Co-Tangent in Radians ", . @ BTN,,14,3,2,4 'M-' i6 . @ TIP," Subtract the current total from Memory", . @ BTN,,14,9,1,3 'Dr' i6 . @ TIP," Radians expressed in Degrees ", . @ BTN,,14,12,1,3 'Ex' i6 . @ TIP," Natural Number E raised to the Power of X ", . @ BTN,,14,15,1,3 'Fp' i6 . @ TIP," Fractional Portion of X ", . @ BTN,,14,18,1,3 'Hc' i6 . @ TIP," Hyperbolic Cosine of X ", . @ BTN,,14,21,1,3 'Hs' i6 . @ TIP," Hyperbolic Sine of X ", . @ BTN,,14,24,1,3 'Ht' i6 . @ TIP," Hyperbolic Tangent of X ", . @ BTN,,14,27,1,3 'Ip' i6 . @ TIP," Interger Portion of X ", . @ BTN,,15,9,1,3 'Le' i6 . @ TIP," Logarithm of X in Base E ", . @ BTN,,15,12,1,3 'Lt' i6 . @ TIP," Logarithm of X in Base 10 ", . @ BTN,,15,15,1,3 'Pi' i6 . @ TIP," Would you like a piece of apple PI? ", . @ BTN,,15,18,1,3 'Rd' i6 . @ TIP," X Degrees in Radians ", . @ BTN,,15,21,1,3 'Si' i6 . @ TIP," Sine of X Radians ", . @ BTN,,15,24,1,3 'Sr' i6 . @ TIP," Square Root of X ", . @ BTN,,15,27,1,3 'Ta' i6 . @ TIP," Tangent of X Radians ", FON,t . @0005:TXT,"", IF > 0 JUV,r ;. @ CLS, EDT,"(p)",,2,9,1,15,,3r SHW, . @0007:INP,,, ,(0010),,(0020),<0>,(0030),<1>,(0031),<2>,(0032),\ <3>,(0033),<4>,(0034),<5>,(0035),<6>,(0036),<7>,(0037),\ <8>,(0038),<9>,(0039),

,,,y . ;SC q CS . @ GTO 0007 . @. @. ----------------------------------------------------------------------------- @. Error Messages @. ----------------------------------------------------------------------------- @0151:LDV ='I do not understand your input. Please try again.' GTO 0160 . @0152:LDV ='Valid range is -1 to +1' GTO 0160 . @0153:LDV ='Valid range is 0 to 709' GTO 0160 . @0154:LDV ='Valid range is -710 to 710' GTO 0160 . @0155:LDV ='Number must be greater than 0' GTO 0160 . @0156:LDV ='You cannot divide by zero' . @0160:LDV =,='' MBX,,s,'Input error' (p)' ' O,(0005) . @. @. ----------------------------------------------------------------------------- @. Run GURU @. ----------------------------------------------------------------------------- @0185:IF DRW1$ > 0 RNM,-1 -0 . ;BRK DLR,-0 . @ CLK CLS RUN GURU . @. @. ----------------------------------------------------------------------------- @. Help @. ----------------------------------------------------------------------------- @0188:BRK . Enter numbers either via the keyboard or by clicking the number buttons. If you use the keyboard, transmit your input by pressing the Enter key, or it will be discarded. You can also enter the "alpha" commands via the keyboard: C (Clear), CE (Clear Entry), MR (Memory Recall), MC (Memory Clear), M+ (Add to Memory), and M- (Subtract from Memory). Even though it is possible to enter via both the keyboard and mouse, I recommend that you stick with one method because of the subtle differences between the two. CALC starts in add mode, as indicated by a "+" in the current operator box to the right of the entry area. You can change mode of operation by clicking the "+", "-", "*", or "/" buttons, or via the other methods described below. When entering from the keyboard, you can change the operator for either the current entry only or for all subsequent entries (until the operator is changed again). For example, if in add mode and you transmit -15, then subtraction becomes the active operator for the current calculation only, and 15 will be subtracted from the total. However, the mode of operation remains addition. If you enter 15- then 15 is added to the total, and the mode of operation becomes subtraction for subsequent entries. Normally you enter one number at a time, but CALC also accepts simple "in-line" calculations. For example, suppose you added a series of numbers, and that the current total is 88. If you then enter 4*17 CALC will display a popup message to inform you that the result of the in-line calculation is 68, that the current total is 88, and that the result of adding 68 to 88 will be 156. CALC then asks if you want to proceed to add the in-line result to the current total. If you choose not to, the current total of 88 is re-displayed. Note: you cannot enter compound equations in-line, such as (12*45)+77.8. To perform this equation, you could enter 77.8 (with the current operator being "+") and then enter 12*45. CALC will display the popup message, and if you accept the inline calculation, the new total of 617.8 will be displayed. Also note that the inline operator (in this example it is multiply) does not alter the current mode of operation (+), so entering subsequent numbers will continue to add them to the running total. Click M+ or M- to modify the value in memory. The current total will be added to or subtracted from memory, which is initially set to zero. If entering via the keyboard, transmit prior to clicking M+ or M- or your entry will be discarded. You can also type M+ or M- and transmit. When memory is activated an "M" will be displayed in the box to the left of the input area. To recall and display stored memory, click MR or the "M" in the "Memory Active" box to the left of the input area. The stored number will be displayed, but you must still process it by transmitting or clicking an operation button. If the total exceeds 15 digits, it will be displayed in scientific notation, where the letter E followed by a number (representing the power of 10) indicates which direction and how many positions to move the decimal point. For example, 173E6 would represent 173,000,000. In this case, E6 is indicating that there are six zeroes to the right of the number 173. Another example is .12345E-3, which represents .00012345, where E-3 indicates three zeroes to the left. Please note that a number shown in scientific notation may be rounded. Also note that you cannot enter scientific notation as input. The 3 rows of buttons on the bottom are for scientific calculations, and are defined as follows: Ab = Absolute value Ac = Arc cosine As = Arc sine At = Arc tangent Cr = Cube root Cc = cosine Ct = Cotangent Dr = Degrees radian Ex = Exponentiate "e" Fp = Fractional portion Hc = Hyperbolic cosine Hs = Hyperbolic sine Ht = Hyperbolic tangent Ip = Integer portion Le = Logarithm base "e" Lt = Logarithm base 10 Pi = Value of PI Rd = Radian degrees Si = Sine Sr = Square root Ta = Tangent CALC keeps a running "ticker" of your calculations. You can display the ticker at any time by clicking Ticker on the menubar. When the ticker is displayed, you can print it if desired via Options on the menubar. Click Back to return to CALC. When you click Clear (all), the ticker running totals are reset, but your previous calculations will remain in the ticker for your viewing pleasure. Note: Scientific Calculations are not recorded in the ticker. Warning! Fuzzy Logic ahead... Transmitting is iterative. For example, if you''re in add mode amd the current total is 2, transmit and CALC will add 2 to the current total, yielding a new total of 4. A second transmit adds 4 to itself, yielding 8. A 3rd transmit adds 8 to 8, yielding 16, and so on. This is probably only useful in add mode. In a nutshell, if you transmit a second time while in add mode, the current total will be doubled. Good luck finding a real use for this, but enter a 2 and transmit repeatedly to see why your computer prefers certain numbers, and why in computer-speak 1K is actually 1,024. The following information is for Run Designers. CALC can be run stand-alone, @LNKed, or @CALLed. When called, if you pass CALC a variable the Grand Total will be returned to the calling run. The syntax for a call is: @CALL,''GURU'',86 1*('') where ''GURU'' is the GURU drawer named during the GURU installation. Note: CALC initializes '' as ''a15. If linked, CALC loads the Grand Total in an environmental variable initialized as '<$GT>'a15. This variable will exist for the duration of the user''s session unless you perform a @CLV,e (note that this clears ALL environmental variables). Whether @LNKed or @CALLed, CALC returns a "Ticker" result that lists of all calculations performed. If you''re run creates a result that needs to be retained, be sure to rename it before accessing CALC. @ BRK WIN,,4,14,23,69,,ho ' GURU Calculator Help' i6 . @ MNU,, MENUBAR,"&Return",,'' . @ LST,-0,2,y,CALC_Help,,2,3,20,65, '' HID, SHW, INP,,, . @ CLS, GTO 0005 . @. @. ----------------------------------------------------------------------------- @. Fatal Error @. ----------------------------------------------------------------------------- @0198:SC q ATT;EEL;FLD,1,1,,SCNH$,c,(WHI/RED),,\ TIC$'<< Sorry, but CALC can only be run on a GUI Workstation >>'TIC$ WAT 4000 . @. @. ----------------------------------------------------------------------------- @. QED @. ----------------------------------------------------------------------------- @0199:CLS, IF RUN$ = CALC . ;RETURN . @ IF LINK$ = 0 LZR,-1,LIN1 DSX,-1,
. ;LDV <$GT>a15= GTO END . @ REL . ................................ Variable Table ................................ . - = Screen Colors .<0> - <9> = Handles: 0 thru 9 . = Handle: Add (+) . = Handle: Clear (C) . = Column Counter . = Handle: Clear Entry (CE) . = Handle: Divide (/) .
= Displayed Line # . = Handle: Equals (=) . = Handle: Edit Box . = Function . = First-Time Flag - used to skip the first write to -2 . = Grand Total . = Horizontal Size of the screen . = Handle: Help Window . = Input . = Packed version of . = Line # . = Line # in -0 result from ticker . = Last Line # in -2 . . = Last Operation . = Messages . = Handle: Memory Add . = Memory Flag (equals X if memory is active) . = Handle: Memory Flag . = Handle: Memory Subtract . = Memory Total . = Memory Popup Text . = Handle: Multiply (*) . = 1st Number in a compound entry (if A+B is entered, = A) . = 2nd Number in a compound entry (if A+B is entered, = B) . = Current Operation (+, -, *, /) . = Handle: Current Operation .

= Handle: Period (.) . = Handle: Subtract (-) . = Temporary Holder . = Temporary Total . = Handle: Window . . All variables initialized for the scientific function buttons represent . their associated handles.

,(0040),,(0045),,(0046),\ ,(0047),,(0048),,(0025),,(0050),,(0055),\ ,(0056),,(0058),,(0060),,(0062),\ ,(0064),,(0066),,(0068),,(0070),\ ,(0072),,(0074),,(0076),,(0078),\ ,(0080),,(0082),,(0084),,(0086),\ ,(0088),,(0090),,(0092),,(0094),\ ,(0096),,(0100),,(0103),,(0103),\ ,(0105),,(0108) ;. @ IF INPUT$(1-2) = L: IF INPUT$(3-4) ge 1 & le MAXLAB$ GTO INPUT$(3-4) ;. @ GTO 0151 . @. @. ----------------------------------------------------------------------------- @. Get the Input and Decide What To Do @. ----------------------------------------------------------------------------- @0010:CHG INPUT$ LCV '' ','/'' DEF,x , . <- kill commas @ IF = 1,9,(0018),2,4,6,(LIN1),5,(0015) ;GTO 0151 . <- valid input? @ LDV,l IF = +,-,*,/ LDV = GTO 0028 ;. <- entered an operator? @ IF = C,(0050),CE,(0055),MC,(0100),MR,(0103),M+,(0105),M-,(0108) ;. @ GTO 0151 . @0015:LDV,r IF (15-1) = +,-,*,/ LDV =(15-1),(15-1)='' GTO 0020 . @ LDV,l IF (1-1) = +,-,*,/ LDV =(1-1),(1-1)='' GTO 0020 ;. @ GTO 0115 . <- we have an inline calculation @0018:LDV,l IF (1-1) = +,-,*,/ LDV =(1-1),(1-1)='' ;. @0020:LDV,r ,= . @. @. ----------------------------------------------------------------------------- @. Calculate it and Display the new Total @. ----------------------------------------------------------------------------- @0025:IF ne '/' . ;IF ne 0 . ;GTO 0156 . <- can't divide by zero! @ IF ne '' . ;LDV =0 . <- it can't be blank @ LDV = ART . <- calc it @ IF = X . ;LDV =X GTO 0028 . @ LDV,r INC IF le . ;LN+,-2,,88 . @ WRL,-2,,y 2-15,18-1,20-15,36-1,38-15,54-15 ,,,,=,, @0028:LDV =,=,='' GTO 0005 . <- show new total @. @. ----------------------------------------------------------------------------- @. They clicked a Number or the Period @. ----------------------------------------------------------------------------- @0030:LDV =0 GTO 0041 . <- "0" button @0031:LDV =1 GTO 0041 . <- "1" button @0032:LDV =2 GTO 0041 . <- "2" button @0033:LDV =3 GTO 0041 . <- "3" button @0034:LDV =4 GTO 0041 . <- "4" button @0035:LDV =5 GTO 0041 . <- "5" button @0036:LDV =6 GTO 0041 . <- "6" button @0037:LDV =7 GTO 0041 . <- "7" button @0038:LDV =8 GTO 0041 . <- "8" button @0039:LDV =9 GTO 0041 . <- "9" button @0040:LDV ='.' . <- "." button @0041:LDV,l LDV (0-1)= LCV T@ ' '/'' LDV,r ,= . @ GTO 0005 . <- accumulate input @. @. ----------------------------------------------------------------------------- @. They clicked an Operator @. ----------------------------------------------------------------------------- @0045:LDV =+ GTO 0025 . <- "+" button @0046:LDV =- GTO 0025 . <- "-" button @0047:LDV =* GTO 0025 . <- "*" button @0048:LDV =/ GTO 0025 . <- "/" button @. @. ----------------------------------------------------------------------------- @. They clicked Clear All or Clear Entry @. ----------------------------------------------------------------------------- @0050:LDV,r =,=0,=0,=+,=+,='' . <- clear all @ IF > 5 . ;GTO 0005 . <- restart tckr @ LN+,-2,,3 INC WRL,-2,,y 2-68\ *,******************************************************************** . @ INC WRL,-2,,y 2-68\ *,'*************** Current calculations have been cleared *************' . @ INC WRL,-2,,y 2-68\ *,******************************************************************** . @ GTO 0005 . @0055:LDV =,='' GTO 0005 . <- clear entry @. @. ----------------------------------------------------------------------------- @. Scientific Calculations Section @. ----------------------------------------------------------------------------- @0056:LDV h3=ABS GTO 0098 . <- absolute value or magnitude @0058:IF ge -1 & le 1 LDV h4=ACOS GTO 0098 ;GTO 0152 . <- arc cosine @0060:IF ge -1 & le 1 LDV h4=ASIN GTO 0098 ;GTO 0152 . <- arc sine @0062:LDV h4=ATAN GTO 0098 . <- arc tangent @0064:LDV h4=CBRT GTO 0098 . <- cube root @0066:LDV h3=COS GTO 0098 . <- cosine @0068:LDV h3=CTN GTO 0098 . <- cotangent @0070:LDV h3=DEG GTO 0098 . <- radians expressed in degrees @0072:IF ge 0 & le 709 LDV h3=EXP GTO 0098 ;GTO 0153 . <-exponent(E to n) @0074:LDV h4=FRAC GTO 0098 . <- fractional portion @0076:IF ge -710 & le 710 LDV h4=HCOS GTO 0098 ;GTO 0154 . <- hyprblc cs @0078:IF ge -710 & le 710 LDV h4=HSIN GTO 0098 ;GTO 0154 . <- hyprblc sn @0080:LDV h4=HTAN GTO 0098 . <- hyperbolic tangent @0082:LDV h3=INT GTO 0098 . <- integer portion @0084:IF > 0 LDV h3=LOG GTO 0098 ;GTO 0155 . <- logarith in base e @0086:IF > 0 LDV h5=LOG10 GTO 0098 ;GTO 0155 . <- logarith in base 10 @0088:ART PI LDV = GTO 0005 . <- pi @0090:LDV h3=RAD GTO 0098 . <- degrees in radians @0092:LDV h3=SIN GTO 0098 . <- sine @0094:IF > 0 LDV h4=SQRT GTO 0098 ;GTO 0155 . <- square root @0096:LDV h3=TAN . <- tangent @0098:IF ne '' LDV,p a15= . ;LDV i1=1 . @ XQT '@ART ''('') ' . <- scientific calculation @ GTO 0005 . @. @. ----------------------------------------------------------------------------- @. Memory Operations @. ----------------------------------------------------------------------------- @0100:TXT," ", LDV ='',=,= GTO 0005 . <- clear memory flag @ LDV ='Memory is currently empty' TIP," (p) ",. @ IF > 5 WRL,-2,,y 54-15 , ;GTO 0005 . @0103:LDV =,= GTO 0005 . <- recall memory @0105:IF ne '' & ne M+ ART + LDV = . ;\ <- memory + IF = M+ LDV =,= ;. @ GTO 0110 . @0108:IF ne '' & ne M- ART - LDV = . ;\ <- memory - IF = M- LDV =,= ;. @0110:IF = '' TXT,"M", LDV =X ;. @ LDV ='Current value in Memory = '(p) TIP," (p) ", . @ WRL,-2,,y 54-15 , GTO 0005 . @. ----------------------------------------------------------------------------- @. Perform an in-line calculation @. ----------------------------------------------------------------------------- @0115:LCV,LIN1 '' '+' GTO 0120 . @ LCV,LIN1 '' '-' GTO 0120 . @ LCV,LIN1 '' '*' GTO 0120 . @ LCV,0151 '' '/' . @0120:LDV =(-1) DEC . @ LDV =(1-) INC,2 LDV =(-0),= . @ ART ;A , LDV = . @ IF = + LDV h3=add,h2=to GTO 0125 ;. @ IF = - LDV h8=subtract,h4=from GTO 0125 ;. @ IF = * LDV h8=multiply,h2=by GTO 0125 ;. @ LDV h6=divide,h4=into . @0125:MBX,yn,i,'In-line Result'\ 'The result of your in-line calculation is '(p)' '//\ 'Do you want to '' it '' the total?'//\ ' (The current total is '(p)','/\ ' and the new total will be '(p)')' Y,(0025),N,(LIN1) . @ LDV = GTO 0005 . @. @. ----------------------------------------------------------------------------- @. Show the CALC Ticker @. ----------------------------------------------------------------------------- @0130:SRH,-2,6,,LIN1 @ADN 2-68 ,@ LLN,-0 LN+,-0,,1 . @ HID, LDV,c ='Press F1 to return to CALC' KEY DSP,-0,,,,,, . @ SHW, IF DRW1$ > 0 DSP,-1,