www.MethowValley.org-2023

Tristan Glib's Posts
User avatar
tristanbgilb
Posts: 1048
Joined: Tue Sep 01, 2020 9:20 pm
Contact:

Re: www.MethowValley.org

Post by tristanbgilb »

This is what I pulled out of Avenger. I might still need to do some different character settings.

Code: Select all

# REM _3_ __:_____*_;_:_3-__(+5 > 5   
#     4 5   4 3   2 5 5 -_=   AAAAAAA
     1  REM [HEX:\
02,1F,64,00,FF,02,0E,01,\
7E,58,8A,58,97,58,99,58,\
8E,5B,1F,16,02,08,10,15,\
21,00,12,00,21,00,00,00,\
20,00,21,00,00,00,20,00,\
1F,00,00,00,1E,00,21,00,\
21,00,16,F9,14,00,00,00,\
26,26,26,26,26,26,26,26 ]


# REM Y_M__Y_M__Y M__M__E£___ _6___£ _
#     6£__$ _6:_5  6__5/_Y6Q 7X_ 4_E£
     2  REM [HEX:\
3E,05,32,82,40,3E,01,32,\
84,40,3E,00,32,83,40,32,\
85,40,2A,0C,40,01,07,00,\
09,22,8A,40,01,0C,00,09,\
22,8C,40,01,0D,00,09,22,\
8E,40,21,00,00,22,88,40,\
21,98,40,3E,22,36,00,23,\
3D,FE,00,20,F8,2A,0C,40,\
01,22,00,09,22,90,40,01,\
F5,02,09,22,92,40,21,02,\
0B,22,96,40,21,1F,17,22,\
94,40,2A,0C,40,01,F8,02,\
09,3E,20,36,80,23,3D,FE,\
00,20,F8,C9,27,27,27,27,\
27,27,27,27,27,27,27,27,\
27,27,27,27,27,27,27,27 ]


# REM __JE£_7)5 SC__;/________JE£_7)5 
#     SC__;/_TC______CCCCCCCCCCCCCCCC
     3  REM [HEX:\
C5,F5,AF,2A,0C,40,23,11,\
21,00,B8,28,04,05,19,18,\
F9,09,F1,77,C1,C9,D5,C5,\
AF,2A,0C,40,23,11,21,00,\
B8,28,04,05,19,18,F9,B9,\
28,01,09,7E,C1,D1,C9,28,\
28,28,28,28,28,28,28,28,\
28,28,28,28,28,28,28,28 ]


# REM _E___Q_     6_____C:1U___ C_XM__
#     /__2 -.Q*7_V4__FF_V4___6 __V4__
     4  REM [HEX:\
E5,2A,88,40,CD,B6,47,00,\
00,00,00,00,22,88,40,7B,\
FE,01,28,0E,1D,3A,82,40,\
FE,00,28,06,3D,32,82,40,\
18,ED,E1,1E,00,16,1B,36,\
17,23,7E,BB,20,01,72,2B,\
2B,7E,BB,20,01,72,01,22,\
00,09,7E,BB,20,01,72,01,\
42,00,AF,ED,42,7E,BB,20,\
01,72,01,21,00,09,AF,BA,\
28,10,06,11,0E,FF,0D,20,\
FD,10,F9,16,00,1E,1B,72,\
18,C7,3A,33,40,5F,3A,32,\
40,8E,FE,00,20,03,3A,34,\
40,3C,3C,32,32,40,3A,85,\
40,CB,FF,32,85,40,C9,29 ]


# REM _<C___C__.CT_ CP__4_Y_/A_:4_Y2/2
#     __4_YC/-_T4_YM/:_O4)Y_M__   Y 2
     5  REM [HEX:\
FE,13,28,44,FE,87,28,40,\
FE,1B,28,39,FE,80,28,35,\
FE,09,20,04,3E,0A,18,26,\
FE,8E,20,04,3E,1E,18,1E,\
FE,82,20,04,3E,28,18,16,\
FE,B9,20,04,3E,32,18,0E,\
FE,34,20,11,3E,64,32,84,\
40,00,00,00,3E,00,1E,01,\
CD,94,41,36,14,3E,01,C9,\
3E,00,C9,2A,2A,2A,2A,2A,\
2A,2A,2A,2A,2A,2A,2A,2A,\
2A,2A,2A,2A,2A,2A,2A,2A ]


# REM JS4<U_______M__ _:_2 />___U___ 4
#     _F__.4_Q J0___K_£/:_(K_£_U___ 4
     6  REM [HEX:\
AF,B8,20,13,3A,85,40,CB,\
47,C8,CB,87,32,85,40,00,\
44,0E,04,1E,00,18,12,CD,\
64,41,3A,84,40,FE,00,20,\
01,2B,7E,FE,1B,20,02,36,\
00,AF,1C,7B,FE,0A,30,03,\
0C,18,0E,FE,10,30,01,0C,\
04,3A,84,40,FE,00,20,01,\
0D,CD,64,41,FE,00,28,0E,\
FE,16,28,0A,CD,1E,42,FE,\
00,28,03,06,00,C9,36,1B,\
C9,2B,2B,2B,2B,2B,2B,2B ]


# REM JS_U___ 4_$___ __4__T**_/6__C__-C
#     __ 4NQ E-_J_WC_S____J___S_$____
     7  REM [HEX:\
AF,B8,C8,3A,84,40,FE,00,\
20,01,0D,CD,64,41,00,FE,\
82,20,06,78,B9,D8,05,18,\
22,FE,87,28,08,FE,16,28,\
04,FE,00,20,33,36,00,2A,\
96,40,AF,78,BC,28,05,38,\
02,05,05,04,AF,79,FE,03,\
38,01,0D,CD,64,41,FE,00,\
28,13,FE,16,28,0F,FE,87,\
28,0B,FE,80,20,0A,0C,23,\
7E,FE,00,20,03,36,87,C9,\
FE,83,28,0E,FE,8A,28,0A,\
FE,1B,20,0D,1E,01,3E,0A,\
18,04,1E,03,3E,00,CD,94,\
41,06,00,C9,06,00,C9,2C,\
2C,2C,2C,2C,2C,2C,2C,2C ]


# REM JS47_$Y_T_J_S_J____F$__ C____K_J
#     _/J__ ____U___ 4_JT4__ _F__.C:_
     8  REM [HEX:\
AF,B8,20,23,4D,0D,3E,03,\
B9,D0,AF,44,B8,C8,AF,CD,\
64,41,C5,2B,0D,7E,FE,80,\
28,09,79,FE,05,30,F4,AF,\
C1,18,2F,C1,06,00,C9,CD,\
64,41,3A,84,40,FE,00,20,\
08,AF,B9,20,03,06,00,C9,\
2B,7E,FE,1B,28,0E,FE,00,\
28,0A,FE,16,28,06,FE,13,\
28,04,18,19,36,00,AF,B9,\
28,22,0D,CD,64,41,FE,00,\
28,08,FE,16,28,04,FE,1B,\
20,03,36,1B,C9,FE,83,28,\
04,FE,8A,20,07,1E,02,3E,\
00,CD,94,41,06,00,C9,2D,\
2D,2D,2D,2D,2D,2D,2D,2D ]


# REM JS4-UM____:3_____ 4_Q<__ _JS_U__
#     _ 4_JT4__ _$____<C>_-C__.4_2_Y_
     9  REM [HEX:\
AF,B8,20,16,3A,32,40,FE,\
05,D0,0E,1F,43,CD,64,41,\
FE,00,20,03,36,13,C9,06,\
00,C9,AF,B8,C8,3A,84,40,\
FE,00,20,08,AF,B9,20,03,\
06,00,C9,0D,CD,64,41,FE,\
13,28,12,FE,16,28,04,FE,\
1B,20,07,1E,01,3E,0A,CD,\
94,41,06,00,C9,11,21,00,\
E5,19,7E,E1,FE,B9,18,06,\
3A,32,40,FE,32,D0,36,00,\
AF,3A,34,40,CB,57,28,18,\
3A,97,40,B8,38,07,19,04,\
7E,FE,00,28,0B,AF,ED,52,\
05,7E,FE,00,28,02,19,04,\
36,13,C9,2E,2E,2E,2E,2E ]


# REM JU____C_WM__?8_Y M__Y-__(__3 <__
#     ._K<<_ C_X/_UO__UM____=_JY XS__
    10  REM [HEX:\
AF,3A,84,40,FE,05,28,07,\
3C,32,84,40,C3,A4,45,3E,\
00,32,84,40,3E,16,ED,5B,\
90,40,01,1F,00,13,62,6B,\
1B,ED,B0,13,13,FE,00,28,\
03,3D,18,EE,3A,34,40,67,\
3A,32,40,6F,ED,4B,94,40,\
AF,3E,80,BD,38,01,04,AF,\
3E,80,BD,30,01,05,AF,3E,\
CE,BC,38,01,04,AF,3E,32,\
BC,30,01,05,AF,3E,06,B8,\
38,02,06,06,AF,3E,17,B8,\
30,02,06,17,ED,43,94,40,\
2A,0C,40,11,41,00,0E,01,\
19,11,21,00,AF,79,FE,17,\
28,0D,B8,30,04,36,00,18,\
02,36,80,0C,19,18,ED,2A,\
32,40,54,5D,29,29,19,29,\
29,29,19,23,22,32,40,C3,\
1E,45,2F,2F,2F,2F,2F,2F ]


# REM __=__JUM__/K_/M__K_Y____/B__K,YT
#     ___EE_Y W4-_Y<___£__E_/___K_Y:_
    11  REM [HEX:\
ED,4B,94,40,05,AF,3A,32,\
40,FE,98,30,02,18,32,FE,\
C1,30,07,3E,09,CD,4E,41,\
18,27,FE,CA,30,1A,3E,B9,\
CD,4E,41,2A,AA,40,3E,00,\
BC,20,16,05,3E,13,CD,4E,\
41,0C,ED,43,AA,40,18,09,\
FE,F3,30,07,3E,8E,CD,4E,\
41,18,2A,FE,FC,30,21,3E,\
82,CD,4E,41,2A,B0,40,3E,\
00,BC,20,07,0C,ED,43,B0,\
40,18,12,2A,B2,40,BC,20,\
0C,0C,ED,43,B2,40,18,05,\
3E,34,CD,4E,41,C3,A4,45,\
30,30,30,30,30,30,30,30,\
30,30,30,30,30,30,30,30 ]


# REM __-____U____C*_?M__2=7__-4_Q __ 
#     C_1/______ _Q F_$_ 4_U9___C__X4
    12  REM [HEX:\
ED,4B,96,40,CD,64,41,3A,\
85,40,CB,4F,28,17,CB,8F,\
32,85,40,1E,14,23,7E,FE,\
16,20,02,36,00,7B,FE,00,\
28,03,1D,18,F0,CD,64,41,\
7E,FE,80,C8,36,00,2B,79,\
0D,FE,00,20,F3,3A,25,40,\
FE,FD,28,04,FE,BD,20,09,\
05,78,FE,00,20,12,04,18,\
0F,FE,FE,28,04,FE,BE,20,\
07,04,78,FE,18,20,01,05,\
0E,02,ED,43,96,40,CD,64,\
41,FE,00,28,07,FE,1B,28,\
03,FE,87,C0,36,83,2B,7E,\
FE,00,28,07,FE,1B,28,03,\
FE,87,C0,36,8A,2B,7E,FE,\
00,28,07,FE,1B,28,03,FE,\
87,C0,36,84,23,23,C3,4A,\
46,32,32,32,32,32,32,32,\
32,32,32,32,32,32,32,32 ]


# REM U9__ZC£_XC__ZC__Y4PU___2_Y_UCE=1
#     V4__M__U____M__2=7__ C__,__ 4_Q
    13  REM [HEX:\
3A,25,40,FE,BF,28,0C,FE,\
BD,28,08,FE,3F,28,04,FE,\
BE,20,35,3A,83,40,57,1E,\
6A,3E,64,BA,28,2A,14,1D,\
BB,20,F8,7A,32,83,40,3A,\
85,40,CB,CF,32,85,40,1E,\
14,23,7E,FE,00,28,07,CD,\
1A,42,FE,00,20,0A,36,16,\
7B,FE,00,28,03,1D,18,E9,\
3A,25,40,FE,7F,28,04,FE,\
7F,20,08,3A,85,40,CB,C7,\
32,85,40,ED,4B,98,40,3A,\
B4,40,5F,2A,96,40,CD,80,\
42,ED,43,98,40,7B,32,B4,\
40,ED,4B,9A,40,3A,B5,40,\
5F,2A,96,40,CD,80,42,ED,\
43,9A,40,7B,32,B5,40,ED,\
4B,9C,40,3A,B6,40,5F,2A,\
96,40,CD,80,42,ED,43,9C,\
40,7B,32,B6,40,3A,83,40,\
FE,00,28,04,3D,32,83,40,\
3A,85,40,CB,87,32,85,40,\
C3,10,47,33,33,33,33,33,\
33,33,33,33,33,33,33,33 ]


# REM __4_E2_   __4___2_2______2_____6
#     ______6___A_E8_   __A___8_2____
    14  REM [HEX:\
ED,4B,A0,40,2A,9E,40,00,\
00,00,ED,43,A0,40,ED,4B,\
9E,40,1E,05,CD,F2,43,ED,\
43,9E,40,60,69,ED,4B,A2,\
40,CD,6C,43,ED,43,A2,40,\
ED,4B,A6,40,2A,A4,40,00,\
00,00,ED,43,A6,40,ED,4B,\
A4,40,1E,08,CD,F2,43,ED,\
43,A4,40,60,69,ED,4B,A8,\
40,CD,6C,43,ED,43,A8,40,\
ED,4B,AC,40,2A,AA,40,00,\
00,00,ED,43,AC,40,ED,4B,\
AA,40,CD,0C,44,ED,43,AA,\
40,60,69,ED,4B,AE,40,CD,\
6C,43,ED,43,AE,40,ED,4B,\
B0,40,CD,E6,42,ED,43,B0,\
40,ED,4B,B2,40,CD,E6,42,\
ED,43,B2,40,C3,FC,47,34,\
34,34,34,34,34,34,34,34,\
34,34,34,34,34,34,34,34 ]


# REM _ ___JE£___ 4_Y0W_A4_Q0F/___X_7/
#     _     __: /_£/K_JY0__A"Y+_PPPPP
    15  REM [HEX:\
FE,00,C8,E5,F5,AF,2A,8C,\
40,7E,FE,80,20,02,3E,9C,\
3C,FE,A6,20,05,36,9C,2B,\
18,EF,77,F1,3D,E1,23,18,\
DF,00,00,00,00,00,06,0A,\
0E,00,18,01,0C,98,30,FC,\
AF,3E,9C,81,FE,A6,C0,3E,\
95,C9,35,35,35,35,35,35 ]


# REM JE£_)_ ;__ 4_Y0W_A4_Q0F/__E__76_
#     _JU___Y0_E£_), ;_JU___>=_E£_)4 ;
    16  REM [HEX:\
AF,2A,0C,40,11,07,00,19,\
7E,FE,80,20,02,3E,9C,3C,\
FE,A6,20,05,36,9C,2B,18,\
EF,77,2A,86,40,23,22,86,\
40,AF,3A,82,40,67,3E,9C,\
84,2A,0C,40,11,1A,00,19,\
77,AF,3A,83,40,CD,DC,47,\
2A,0C,40,11,20,00,19,77,\
AF,3A,85,40,CB,7F,28,07,\
CB,BF,32,85,40,18,09,06,\
05,0E,FF,0D,20,FD,10,F9,\
3A,82,40,FE,00,C8,3A,84,\
40,FE,64,C8,AF,3A,84,40,\
FE,05,20,0E,ED,4B,96,40,\
CD,64,41,3E,00,77,2B,77,\
2B,77,C3,78,44,78,44,36 ]

    17 DIM H(5)
    18 DIM M(5)
    20 LET T=0
    21 LET S=0
    22 RAND 
    23 LET SHIP=1
    25 GOTO 5000
    30 POKE 16518,0
    35 POKE 16519,0
    40 CLS 
    50 PRINT AT 0,0;"t‰—————««hits‰—————««sld‰«las‰—"
    55 LET A=USR 16584
    60 LET A=USR 17528
    65 IF PEEK 16516=100 THEN GOTO 500
    67 PRINT AT 10,2;"SHIP ";SHIP;" HAS BEEN DESTROYED"
    68 FOR N=1 TO 100
    69 NEXT N
    70 LET T=T+(PEEK 16518+256*PEEK 16519)
    75 LET S=S+(PEEK 16520+256*PEEK 16521)
    80 IF SHIP=5 THEN GOTO 100
    85 LET SHIP=SHIP+1
    90 GOTO 30
   100 CLS 
   101 LET R=(INT (100*(S/T)))/100
   102 PRINT AT 0,6;"AT LEVEL ";U$
   103 LET U=VAL U$
   105 PRINT AT 2,0;"YOUR TOTAL SCORE IS ";S;AT 3,2;"WITH A HIT/TIME RATIO OF ";R
   109 IF S>H(U) THEN LET H(U)=S
   110 IF R>M(U) THEN LET M(U)=R
   118 IF S<=5000 THEN PRINT AT 5,0;"YOU HAVE NOT INFLICTED ENOUGH   DAMAGE TO SECURE THE PLANET."
   120 IF S>5000 THEN PRINT AT 5,0;" YOU HAVE BADLY DAMAGED THE     ALIEN PLANET.                     "
   125 IF S>5000 AND 1.5*S>T THEN PRINT AT 7,0;"THE PLANET IS YOURS."
   130 PRINT AT 10,0;"LEVEL    HIGH SCORE   HIGH RATIO"
   131 PRINT 
   135 FOR N=1 TO 5
   140 PRINT TAB 2;N;TAB 16-LEN (STR$ H(N));H(N);TAB 25;M(N)
   145 NEXT N
   190 PRINT AT 21,0;"PRESS ÀPÀ TO PLAY"
   195 IF NOT INKEY$="P" THEN GOTO 195
   200 GOTO 20
   500 PRINT AT 7,15;"½½"
   505 FOR N=1 TO 10
   506 NEXT N
   510 PRINT AT 7,15;"  "
   511 FOR N=1 TO 10
   512 NEXT N
   515 PRINT AT 7,7;"½½½½½½½½½½½½½½½½½½"
   516 PRINT AT 6,7;"½½½½½½½½½½½½½½½½½½"
   517 PRINT AT 8,7;"¿½½½½½½½½½½½½½½½½¿"
   518 PRINT AT 5,7;"¾½½½½½½½½½½½½½½½½¾"
   519 PRINT AT 9,10;"½½½½½½½½½½½½"
   520 PRINT AT 4,8;"¾½½½½½½½½½½½½½½¾"
   521 PRINT AT 10,11;"¿½½½½½½½½¿"
   522 PRINT AT 3,9;"¾½½½½½½½½½½½½¾"
   523 PRINT AT 11,14;"½½½½"
   524 PRINT AT 2,11;"¾½½½½½½½½¾"
   525 PRINT AT 12,14;"½½½½"
   526 PRINT AT 13,11;"¾¾½½½½½½¾¾"
   527 PRINT AT 14,11;"¿¿½½½½½½¿¿"
   528 PRINT AT 15,14;"½½½½";AT 16,14;"½½½½"
   529 PRINT AT 17,12;"¾½½½½½½¾";AT 18,12;"¿½½½½½½¿"
   530 PRINT AT 19,14;"½½½½";AT 20,14;"½½½½";AT 21,14;"½½½½"
   535 FOR N=1 TO 75
   536 NEXT N
   540 GOTO 67
  5000 CLS 
  5001 PRINT "        A V E N G E R"
  5002 PRINT AT 2,22;"BY K FLYNN"
  5003 PRINT AT 3,8;"(C) ABACUS PROGRAMS 1982"
  5005 PRINT ,," YOU COMMAND THE ZARQON SPACE-  SHIP ÀAVENGERÀ."
  5010 PRINT " YOUR CONTROLS ARE :-"
  5011 PRINT "   UP     - ÀAÀ                    DOWN   - ÀZÀ                    LASER  - ÀLÀ                    BOMBS  - ÀMÀ"
  5012 PRINT " KEY COMBINATIONS ARE :-           A/L , Z/L AND M/L ."
  5016 PRINT ,," USING THE LASER AND BOMBS YOU  MUST ATTACK THE ENEMY PLANET    WHILE PROTECTING YOURSELF."
  5020 PRINT " THE ALIENS WILL FIGHT BACK WITHMISSILE FIRING INTERCEPTORS AND GUIDED MISSILES."
  5021 PRINT AT 21,0;"PRESS ÀPÀ"
  5026 IF NOT INKEY$="P" THEN GOTO 5026
  5027 CLS 
  5030 PRINT "POINTS ARE SCORED AS FOLLOWS :-"
  5031 PRINT "(ÀLÀ INDICATES THAT THE TARGET  WILL BE DESTROYED BY LASER ,    ÀBÀ FOR BOMBS.)"
  5036 PRINT ,,"À<À INTERCEPTOR  10 POINTS (L)"
  5037 PRINT ,,"À²À GUIDED MIS.  10 POINTS (B)"
  5038 PRINT ,,"À¾À BUILDINGS    10 POINTS (L/B)"
  5039 PRINT ,,"À‰À FACTORY      30 POINTS (L/B)"
  5040 PRINT ,,"ÀªÀ MISSILE PAD  40 POINTS (L/B)"
  5041 PRINT ,,"ÀtÀ INTERCEP.PAD 50 POINTS (L/B)"
  5042 PRINT ,,"ÀOÀ ATOMIC POWER STATION ....        D O  N O T  H I T."
  5045 PRINT AT 21,0;"PRESS ÀPÀ"
  5046 IF NOT INKEY$="P" THEN GOTO 5046
  5047 CLS 
  5050 PRINT " THE TOP LINE OF THE DISPLAY    GIVES THE TIME , POINTS ,       SHIELDS AND THE TEMPERATURE OF  THE LASER."
  5055 PRINT " THE SHIP HAS 5 SHIELDS , 1 IS  LOST FOR EACH HIT FROM AN INTER-CEPTOR , 2 FOR EACH GUIDED MIS."
  5060 PRINT " THE TEMP. OF THE LASER RISES   AS IT IS FIRED AND FIRING STOPS WHEN IT EXCEEDS 9."
  5065 PRINT ,," YOU HAVE 5 SHIPS AND MUST SCOREOVER 5000 POINTS TO WIN."
  5066 PRINT AT 18,0;"ENTER LEVEL OF PLAY (1 TO 5)            (5 BEING HARDEST)"
  5067 LET U$=INKEY$
  5069 IF U$<"1" OR U$>"5" THEN GOTO 5067
  5070 LET E=26-(2*(VAL U$))
  5071 POKE 17848,E
  5072 POKE 18042,E
  5074 POKE 18018,(103+(VAL U$))
  5075 POKE 18508,(6-(INT ((VAL U$)/2)))
  5076 POKE 16871,(20-(VAL U$))
  5090 CLS 
  5095 PRINT AT 10,0;"G O O D  L U C K . . ."
  5098 FOR N=1 TO 50
  5099 NEXT N
  5100 GOTO 30
  9000 INPUT I$
  9005 SAVE "AVENGEr"
  9010 RUN 
http://zx81.vb81.free.fr/
Image

Image <=NUCLEAR BUTTONImage

Image

KFAC-LP 105.5 FM Twisp WA
User avatar
tristanbgilb
Posts: 1048
Joined: Tue Sep 01, 2020 9:20 pm
Contact:

Re: www.MethowValley.org

Post by tristanbgilb »

mister_coffee wrote: Thu Jan 26, 2023 7:08 am Wimps, all wimps here.

Blast from the past, about 22 years ago:

Code: Select all

<?
        include("include/wp2001.php");
        include("include/view_functions.php");
        ob_end_flush();
?>
<FORM action="logsheets.php" method=POST>
<?
        if (ereg("r=([0-9]+),d=(.+)",$QUERY_STRING,$matches)) {
                $where = $matches[1];
                $date = mysqldate_to_wp2001($matches[2]);
                $action = "Update";
                $QUERY_STRING = "";
        }

        if ($where == "") {
                $where = cookiejar("zone");
        } else {
                fill_cookiejar("zone",$where);
        }

        $form = new html_table;
        $form->init(array("rows" => 2, "cols" => 2));
        $form->table_style= 'BORDER="1" CELLPADDING="2" CELLSPACING="2"';

        $form->cell[1][1]["content"] = "Where";
        $form->cell[1][2]["content"] = myselector(
                "SELECT id,name FROM resources WHERE type=$zone_resourcetype AND active<>0 ORDER BY name",
                "where",$where);

        $form->cell[2][1]["content"] = "Date (mm/dd)";
        $form->cell[2][2]["content"] = myfield("date",25,$date);

        $form->code();
        $form->display();
?>
<BR>
        <INPUT type=submit name=action value=Update></INPUT>
        </FORM>
  <HR WIDTH="100%">
<?
        if ($action == "Update" and $where != "") {
                $q  = "SELECT resourcemap.right_resource,resources.name ";
                $q .= "FROM resourcemap,resources ";
                $q .= "WHERE resourcemap.left_resource=$where AND ";
                $q .= "resourcemap.right_resource=resources.id AND ";
                $q .= "resources.type=$camp_resourcetype ";
                $q .= "ORDER BY resourcemap.stacking_order";

                $r1 = wpquery($q);

                $i = 0;
                while ($row = mysql_fetch_row($r1)) {
                        $resources[$i]["id"]   = $row[0];
                        $resources[$i]["name"] = $row[1];
                        ++$i;
                }

                mysql_free_result($r1);

                $extras = extra_resource_data($resources);
                $extra_col = 0;

                for ($i = 0; $i < count($resources); $i++) {
                        $x = $extras[$resources[$i]["id"]];
                        $resources[$i]["extra"] = $x;

                        if (strlen($x) > 0) $extra_col = 1;
                }

                $range = new date_range($date);
                $base = 1;

                $tbl = new html_table;
                $tbl->init(array("rows" => $i + 1, "cols" => 8 + $extra_col));
                $tbl->table_style= 'BORDER="1" CELLPADDING="2" CELLSPACING="2"';

                for ($i = 0; $i < 7; $i++) {
                        $range->span($i);
                        $tm = $range->raw_last();
                        $tbl->cell[1][$extra_col + 2 + $i]["content"] =
                                "<strong>" . date("m/d",$tm) .
                                "</strong>";
                        $tbl->col_style[$extra_col + 2 + $i] = "VALIGN=TOP";
                }

                $range->span(7);

                for ($i = 0; $i < count($resources); $i++) {
                        // make the camp be a link to the camps view on
                        // the appropriate dates...
                        $url_tail = "r=" . $resources[$i]["id"] . ",d=" .
                                $range->mysql_first();

                        $tbl->cell[2 + $i][1]["content"] =
                                "<A HREF=\"camps.php?$url_tail\">" .
                                "<small>" . $resources[$i]["name"] .
                                "</small></A>";

                        if ($extra_col) {
                                $tbl->cell[2 + $i][2]["content"] =
                                        "<small>" .
                                        $resources[$i]["extra"] .
                                        "</small>";
                        }

                        $list = camp_report($range,$resources[$i]["id"],0);

                        for ($j = 0; $j < 7; $j++) {
                                if ($list[$j] == "") continue;
                                $tbl->cell [2+$i][$extra_col+2+$j]["content"] =
                                        "<small>" . $list[$j] . "</small>";
                        }
                }

                $tbl->code();
                $tbl->display();
                print "<HR WIDTH=\"100%\">\n";

        }
?>

<h2>How This Works</h2>

<UL>
<LI>If you don't enter a date, we use the current date.<P>

<LI>You can enter a date with a four-digit year for a year other than
the current one.  There is plenty of data for 1999 and 2000.<P>

<LI>Choose a zone and you'll see all the permits for that zone (by camps)
for the next week.<P>

</UL>

<h2>To Think About</h2>

<UL>
<LI>It got too busy and too ugly when displaying assigned camp sites as well.
Speed might be a concern too.<P>

<LI>Perhaps a variant of this tool that generates a printable form of
the logsheets that could be used in emergencies would be a good idea.<P>

</UL>

</BODY>
</HTML>
More recent work:

Code: Select all

@router.post("/status", response_model=StatusResult)
async def post_status(item: StatusItem):
    """
        posts status from a device, status data is in the json payload

        returns a dict with one entry (ok) set to 1 on success
    """
    # FIXME:  confirm we are posting for the logged-in device
    check_location(item.latitude, item.longitude)
    check_device_id(item.device_id)

    when = time.time()

    if item.status != "GREEN":
        statuses = await get_device_status(item.device_id)
        changed = False

        if statuses is None:
            changed = True
        else:
            status = statuses[0]
            if status["status"] != item.status:
                changed = True

        if changed:
            get_logger().info(f"{item.device_id}:  status changed to {item.status}")
            wps = await find_watchpoints(item.latitude, item.longitude)

            if wps is not None and len(wps) > 0:
                await enqueue_detection(
                    item.status, item.device_id, item.latitude, item.longitude, wps
                )

    """
        FIXME:  there is an optimization here where when there is no image data,
        in that case we can gather both of these futures rather than run them sequentially
    """
    await note_db_status(when, item)
    await note_status(when, item)

    return StatusResult(ok=1)

PHP is freaking ugly.
I am not strong in any computer language. I am a wimp programmer. I just like the logic and hope to understand a computer by studying the ZX81.
Image

Image <=NUCLEAR BUTTONImage

Image

KFAC-LP 105.5 FM Twisp WA
User avatar
tristanbgilb
Posts: 1048
Joined: Tue Sep 01, 2020 9:20 pm
Contact:

Re: www.MethowValley.org

Post by tristanbgilb »

http://zx81.vb81.free.fr/

Here is a very powerful ZX81 Emulator. It seems to make the Timex Sinclair 1000 do everything I ever dreamed and more. I am looking for a way to convert this image of the listing into a text file that I can manipulate in the ZX81 and outside the ZX81 in a text editor. I can now write in the text editor and the program will load into the emulator. Now I need to have the listing for Avenger in a text editor to edit and reload.

Attached is an image of the Avenger listing that I will try to convert to text for editing.
Attachments
Avenger Listing.png
Image

Image <=NUCLEAR BUTTONImage

Image

KFAC-LP 105.5 FM Twisp WA
User avatar
pasayten
Posts: 2444
Joined: Thu Mar 11, 2021 8:03 pm
Contact:

Re: www.MethowValley.org

Post by pasayten »

No wimps here... OCEC Electric Rate Calulator... Support program to https://methow.chewack.com/getmybill2022.php

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title>My Methow Information Web Pages</title>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
	<meta name="keywords" content="">
	<meta name="description" content="">
	<!-- master default -->
<link rel="stylesheet" type="text/css" href="mymetbill2.css" />

<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="https://methow.chewack.com/getbill_function24mo2022.js"></script>


<?php
echo '<script type="text/javascript">';
echo 'google.load("visualization", "1", {packages:["corechart","gauge"]});';
echo 'var qsParm = new Array();';
echo 'var kary = new Array();';
echo 'var dary = new Array();';
echo 'var nary = new Array();';

echo 'var pary = new Array();';
echo 'var ravg = new Array();';
echo 'var crb = new Array();';
echo 'var prb = new Array();';
echo 'var chb = new Array();';
echo 'var cbill = 0.0;';
echo 'var pbill = 0.0;';
echo 'var chgbill = 0.0;';
echo 'var kavg = 0;';
echo 'var crank = 0;';
echo 'var kmax = 0;';
echo 'var dmax = 0;';
echo 'var grank = 0;';
echo 'var xtemp = 0.0;';
echo 'var origrate = 0;';
echo 'var newcls = "G1";';
echo 'var oldcls = "Residential";';
echo 'var mary = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];';
// ***********************************
// set default starts
// ***********************************
echo 'var enddat = 2212;';
echo 'var maxrank = 4000;';
$enddat = "2212";


if(isset($_GET['recsel'])) $xkey = $_GET['recsel'];
if(isset($_GET['enddat'])) $enddat = $_GET['enddat'];
$fd = fopen("membertool.log", "a");
$msg = "[" . date("Y/m/d h:i:s", time()) . "] ";
$msg = $msg.' RateCalc Member key: '.$xkey.'/';
$msg = $msg.' End date: '.$enddat.'/';
foreach (array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR') as $key) {
  if (array_key_exists($key, $_SERVER) === true) {
    foreach (explode(',', $_SERVER[$key]) as $ip) {
      if (filter_var($ip, FILTER_VALIDATE_IP) !== false) {
          $msg = $msg.$ip.'/';
      }
    }
  }
}
fwrite($fd, $msg . "\n");
fclose($fd);

 // Otherwise we connect to our Database
$hostname = 'localhost';
$username = '????????';
$password = '????????';
$database = '????????';

$link = mysqli_connect($hostname, $username, $password) or die("Unable to Connect to '$hostname'");
mysqli_select_db($link, $database) or die("Could not open the db '$database'");

 //Now we search for our search term, in the field the user specified
$query="SELECT * FROM mem_tool2022 WHERE member_fake = ";
$query=$query.$xkey;
//$query=$query."'";
//$data = mysql_query($query);
$data = mysqli_query($link, $query);

//echo "data query=".$query.":<br>";
//echo $data;
 //And we display the results
 $i =0;
 // ************************************
 // arrays set for 2001 thru 2212...
 // ************************************
 $kary=array(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1);
 $dary=array(0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0);
 $ravg=array(0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0);
 $totk = 0.0;
 $totd = 0.0;

 while($result = mysqli_fetch_array( $data ))

 {
 $i = $i + 1;
 // Get all regular stuff for meter
 if ($i == 1)
   {
   $cls = $result['class'];
   echo 'crank = '.$result['rank'].';';
   //echo 'debug';
   //echo $result['kwhavg_2022'];
   //echo $result['rank'];
   //echo 'debug';

   echo 'kavg = '.$result['kwhavg_2022'].';';
   //echo 'totk = '.$result['tot_kwh'].';';
   //echo 'totd = '.$result['tot_kw'].';';
   //echo 'totbil = '.$result['tot_rev'].';';
   echo 'phase = '.$result['rate'].';';
   echo 'cur_rate = '.$result['cur_rate'].';';
   // WAS COMMENTED OUT
   echo 'origrate = '.$result['cur_rate'].';';
   $gcls = $result['kwhavg_2022'];
   $xnm = "G1 (0-1200 avg kwh/mth)";
   if ( $gcls > 1200 ) $xnm ="G2 (1200-5000 avg kwh/mth)";
   if ( $gcls > 5000 ) $xnm ="G3 (5000-16,667 avg kwh/mth)";
   if ( $gcls > 16667 ) $xnm ="G4 (Abv 16,667 avg kwh/mth)";
   echo 'newcls = "'.$xnm.'";';
   }
 // Now load kwh/kw arrays
 $xd = $result['billyrmo'];
 $xkwh = $result['kwh'];
 $xdem = $result['kwdemand'];
 if ($xd < 2101) {
   $xd = $xd - 2000;
   $xd = $xd -1;
 } elseif ($xd < 2201) {
   $xd = $xd - 2100;
   $xd = $xd +11;
 } else {
   $xd = $xd - 2200;
   $xd = $xd +23;
 }




 //echo 'xd:'.$xd.' kwh:'.$xkwh.' <br>';
 $kary[$xd] = $xkwh;
 $dary[$xd] = $xdem;
 }

//  Calculate annual running averages
 $rtot = 0;
 $rnum = 0;
 for ($i=11; $i<=35; $i++)
   {
   if ($kary[$i] > -1) {
     // Have value, do running average
     $j = $i - 11;
     $rtot = 0;
	 $rnum = 0;
     for ($j=$i-11; $j<=$i; $j++)
     {
        if ($kary[$j] > -1)
        {
           $rtot = $rtot + $kary[$j];
           $rnum = $rnum + 1;
        }
     }
     $ravg[$i] = $rtot / $rnum;
     //echo 'i: '.$i.' kwh:'.$ravg[$i].' <br>';
   }
 }




 // Now set up annual values for chosen end month
 // VERIFY OFFSET data starts at 1201, not 1101

 if ($enddat == 2112) $istrt = 12;
 if ($enddat > 2112)  $istrt = $enddat - 2200 +12;
 if ($enddat > 2212)  $istrt = $enddat - 2300 +24;
 //if ($enddat == 1309) $istrt = 12;
 //if ($enddat > 1212)  $istrt = $enddat - 1300 +12;
 //if ($enddat > 1312)  $istrt = $enddat - 1400 +12;

 for ($i=0; $i<=11; $i++)
   {
   $ioff = $i + $istrt;
   if ($kary[$ioff] == -1)
   {
     echo 'kary['.$i.'] = -1;';
     echo 'dary['.$i.'] = 0.0;';
     echo 'ravg['.$i.'] = 0.0;';
   } else {
     $totk = $totk + $kary[$ioff];
     $totd = $totd + $dary[$ioff];
     echo 'kary['.$i.'] = '.$kary[$ioff].';';
     echo 'dary['.$i.'] = '.$dary[$ioff].';';
     echo 'ravg['.$i.'] = '.round($ravg[$ioff],1).';';
   }

   if ($kary[$ioff-12] == -1)
   {
     echo 'pary['.$i.'] = -1;';
   } else {
     echo 'pary['.$i.'] = '.$kary[$ioff-12].';';
   }

   }
 echo 'totk = '.$totk.';';
 echo 'totd = '.$totd.';';
 echo 'enddat = '.$enddat.';';
 //$xkey = 792194002;
 echo 'frec = '.$xkey.';';
 $mrec = ( $xkey -1994 ) / 4;
 echo 'mrec = '.$mrec.';';


echo 'google.setOnLoadCallback(getMemberData);';
//echo 'getMemberData();';

echo '</script>';
?>


</head>
<body>
<div style="float: left; width: 800px;border:1px solid black;">

<div style="float: left; clear: left; width: 327px; height: 110px; border-right:1px solid black;border-bottom:1px solid black;border-top:1px solid black;background: rgb(200,229,238);">
<center id="cursive18">My Methow<br>
Electrical<br>
Information</b></center>
</div>

<div style="float: right; width: 470px; height: 110px; border:1px solid black;background: rgb(200,229,238);">
<img src="https://methow.chewack.com/images/mymetlogo3.jpg" />
</div>

<div id="body" style="width:800px;">


<p id="mediumcursive"><center><b>Your OCEC electrical bill summary analysis</b></center><br>

<div style="width:800;height:320px;">
<div id="chart_div" style="width:580;height:320px;float:left;margin-left:10px;border:1px solid black;">
<br><br><span style="width:580px;text-align:center;float:left;">... loading data ...</span></div>

<div style="width:170px;height:240px;float:left;margin-left:20px;margin-top:0px;border:1px solid black;">

<div style="width:170px;height:40px;margin-top:5px;">
<span style="width:165px;text-align:center;float:left;"><p class="txsmall">Your Average Monthly<br>kwh Usage Rank</p></span>
</div>

<div id="gage_div" style="width:160px;height:150px;margin-left:10px;"></div>

<div style="width:170px;height:40px;margin-top:0px;">
<span style="width:165px;text-align:center;float:left;"><p class="txsmall">Scale of 0-100<br> for 4000 meters @ OCEC</p></span>
</div>

<div style="width:170px;height:75px; margin-top:10px; border:1px solid black;">
<span style="width:165px;text-align:center;float:left;"><p class="txsmall">
Choose dates to analyze:<br>
<form name="disptype" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<select name="enddat" style="float:left;height:22px;margin-left:8px;margin-top:5px;background:rgb(200,229,238);">
<?php
$xx = "";
if ($enddat == 2112) $xx = "selected";
echo '<option value="2112" '.$xx.'>Jan 2021-Dec 2021</option>';
$xx = "";
if ($enddat == 2209) $xx = "selected";
echo '<option value="2209" '.$xx.'>Oct 2021-Sep 2022</option>';
$xx = "";
if ($enddat == 2212) $xx = "selected";
echo '<option value="2212" '.$xx.'>Jan 2022-Dec 2022</option>';



echo '</select><br>';
echo '<input style="margin-left:0px;line-height:18px;text-align:center;background: rgb(200,229,238);" type="submit" value="Submit New Dates" />';
echo '<input name="recsel" type="hidden" value="'.$xkey.'" />';


//Pulled out of rate summary
//Energy Chg:
//<span id="pener">0.00</span>
//    Inc kwh:
//<span id="ptier1">0</span>
//<br>








?>

</form>
</p></span>
</div>

</div>

</div>

<div style="width:770px;margin-top:20px;margin-left:20px;">

<p class="tzsmall">
Member Account: <b id="mrec">0</b> Data Record: <b id="frec">0</b><br>
<b>Summary stats are for the 2022 base year:</b> Your monthly avg kwh was <b id="mavg">0</b> and ranked <b id="krank">0</b> from the highest of the approx 4000
OCEC meter accounts.  This is converted to <b id="grk">0</b> out of 100 to display on the gage.
Under the current policies, your average monthly kwh usage would place you in the
<b>General Service Class <span id="newgx">G1</span></b> and
<b>Rate Code <span id="ratecd">1</span></b>.
Your rate class is currently set to <b id="currate">00</b>.
Your current average kwh usage
<span id="classchg">and existing rate meet policies. You might check if a higher rate code would save you money</span>.

<br>
<b>Summary for the selected dates:</b> Your total energy usage for the 12 month period was <b id="tkwh">0</b> kwh.   Your peak monthly usage was <b id="mxkwh">0</b> kwh
and your peak monthly demand was <b id="mxkw">0</b> kw. Following is a summary of your monthly usage and billings using the 2021/22 rates which you can compare with the
a new rate class and other utility/coop/class rates.
Also note yard lights/local taxes have not been included.
</p><br>
<br>
<div style="width:520px;float:left;margin-top:0px;margin-left:0px;border:0px solid black;">

<table class="billtab" border="1">
<tr>
<th>Month</th>
<th>Total kwh</th>
<th>Dem kw</th>
<th id="g2015">2021 xx Rate</th>
<th>Compare Rate</th>
<th>% Change</th>
</tr>

<tr><td id="m1" style="text-align:left;">Jan</td>
<td id="k1">0</td>
<td id="kw1">0</td>
<td id="o1">0.00</td>
<td id="n1">0.00</td>
<td id="c1">0.0%</td></tr>

<tr><td id="m2" style="text-align:left;">Feb</td>
<td id="k2">0</td>
<td id="kw2">0</td>
<td id="o2">0.00</td>
<td id="n2">0.00</td>
<td id="c2">0.0%</td></tr>

<tr><td id="m3" style="text-align:left;">Mar</td>
<td id="k3">0</td>
<td id="kw3">0</td>
<td id="o3">0.00</td>
<td id="n3">0.00</td>
<td id="c3">0.0%</td></tr>

<tr><td id="m4" style="text-align:left;">Apr</td>
<td id="k4">0</td>
<td id="kw4">0</td>
<td id="o4">0.00</td>
<td id="n4">0.00</td>
<td id="c4">0.0%</td></tr>

<tr><td id="m5" style="text-align:left;">May</td>
<td id="k5">0</td>
<td id="kw5">0</td>
<td id="o5">0.00</td>
<td id="n5">0.00</td>
<td id="c5">0.0%</td></tr>

<tr><td id="m6" style="text-align:left;">Jun</td>
<td id="k6">0</td>
<td id="kw6">0</td>
<td id="o6">0.00</td>
<td id="n6">0.00</td>
<td id="c6">0.0%</td></tr>

<tr><td id="m7" style="text-align:left;">Jul</td>
<td id="k7">0</td>
<td id="kw7">0</td>
<td id="o7">0.00</td>
<td id="n7">0.00</td>
<td id="c7">0.0%</td></tr>

<tr><td id="m8" style="text-align:left;">Aug</td>
<td id="k8">0</td>
<td id="kw8">0</td>
<td id="o8">0.00</td>
<td id="n8">0.00</td>
<td id="c8">0.0%</td></tr>

<tr><td id="m9" style="text-align:left;">Sep</td>
<td id="k9">0</td>
<td id="kw9">0</td>
<td id="o9">0.00</td>
<td id="n9">0.00</td>
<td id="c9">0.0%</td></tr>

<tr><td id="m10" style="text-align:left;">Oct</td>
<td id="k10">0</td>
<td id="kw10">0</td>
<td id="o10">0.00</td>
<td id="n10">0.00</td>
<td id="c10">0.0%</td></tr>

<tr><td id="m11" style="text-align:left;">Nov</td>
<td id="k11">0</td>
<td id="kw11">0</td>
<td id="o11">0.00</td>
<td id="n11">0.00</td>
<td id="c11">0.0%</td></tr>

<tr><td id="m12" style="text-align:left;">Dec</td>
<td id="k12">0</td>
<td id="kw12">0</td>
<td id="o12">0.00</td>
<td id="n12">0.00</td>
<td id="c12">0.0%</td></tr>

<tr><td style="text-align:left;"><b>Total</b></td>
<td><b id="k13">0</b></td>
<td><b id="kw13">-</b></td>
<td><b id="o13">0.00</b></td>
<td><b id="n13">0.00</b></td>
<td><b id="c13">0.0%</b></td></tr>
</table>
</div>

<div style="width:250px;float:left;margin-top:0px;margin-left:0px;border:0px solid black;">
<form name="rateform" action="" >
<p class="txsmall"><b>Choose a rate to compare your bill:</b><br>
<select id="kratex" name="kratex" style="float:left;width:240px;height:22px;margin-left:0px;margin-top:10px;background:rgb(200,229,238);" onChange="newbill();">
<option value="1" selected="0">Need rate selection</option>
<option value="201"> OCEC Apr 2023 Gen Serv 1 rate</option>
<option value="202"> OCEC Apr 2023 Gen Serv 2 rate</option>
<option value="203"> OCEC Apr 2023 Gen Serv 3 rate</option>
<option value="204"> OCEC Apr 2023 Gen Serv 4 rate</option>
<option value="205"> OCEC Apr 2023 Irrigation 1P</option>
<option value="206"> OCEC Apr 2023 Irrigation 3P</option>
<option value="181"> OCEC 2021/22 Gen Serv 1 rate</option>
<option value="182"> OCEC 2021/22 Gen Serv 2 rate</option>
<option value="183"> OCEC 2021/22 Gen Serv 3 rate</option>
<option value="184"> OCEC 2021/22 Gen Serv 4 rate</option>
<option value="185"> OCEC 2021/22 Irrigation 1P</option>
<option value="186"> OCEC 2021/22 Irrigation 3P</option>
<option value="18">Big Bend residential rate (chk Nov22)</option>
<option value="15">Chelan PUD residential rate (chk Nov22)</option>
<option value="22">Columbia REA residential rate (chk Jan19)</option>
<option value="4">Colville (Avista) residential rate (chk Nov22)</option>
<option value="12">Ferry County PUD residential rate (chk Nov22)</option>
<option value="11">Inland Power residential rate (chk Nov22)</option>
<option value="19">Kittitas PUD residential rate (chk Nov22)</option>
<option value="91">Lakeview residential rate (chk Nov22)</option>
<option value="9">Nespelum Electric residential rate (chk Nov22)</option>
<option value="2">Okanogan PUD Apr 23 residential rate (chk Jan23)</option>
<option value="3">OPALCO (Island Cty) residential winter rate (chk Nov22)</option>
<option value="5">Oregon Trail Coop residential rate (chk Nov22)</option>
<option value="17">Parkland Light Coop residential rate (chk Nov22)</option>
<option value="21">Pend Oreille PUD residential rate (chk Nov22)</option>
<option value="20">Skamania residential rate (chk Nov22)</option>
<option value="10">Snohomish County PUD residential rate (chk Nov22)</option>
<option value="8">Tanner Electric residential rate (chk Nov22)</option>
<option value="200">Umatilla Electric residential rate Winter (chk Nov22)</option>
<option value="7">Western Oregon Coop residential rate (chk Nov22)</option>
</select>

<br><br>
<span style="width:150px;float:left;">Existing 12mth bill:</span>
<b id="zold" style="width:70px;float:left;text-align:right;">$0.00</b>
<br>
<span style="width:150px;float:left;">Compare 12mth bill:</span>
<b id="znew" style="width:70px;float:left;text-align:right;">$0.00</b>
<br>
<span style="width:230px;float:left;">Inc/(Dec):  
<b id="zchg">$0.00</b>/yr or
<b id="zchgm">$0.00</b>/mth
</span><br></p>
<p class="cursive12">Rate structure used to compare:<br>
<span><b id="pcomp">OCEC current rate</b></span><br>
Base Meter 1P:
<span id="pbase">0.00</span>
    3P:
<span id="pbase3">0.00</span>
<br>
Demand Chg:
<span id="pdem">0.00</span>
    Inc kw:
<span id="pdinc">0</span>
<br>
Base kwh rate:
<span id="prate1">0.0000</span>
<br>
Tier 2 rate:
<span id="prate2">0.0000</span>
    Abv kwh:
<span id="ptier2">0</span>
<br>
Tier 3 rate:
<span id="prate3">0.0000</span>
    Abv kwh:
<span id="ptier3">0</span>
<br>
Cost of power adj:
<span id="pkopa">0.0000</span>
</p>
<input name="kwh01" value="0" type="hidden">
<input name="kwh02" value="0" type="hidden">
<input name="kwh03" value="0" type="hidden">
<input name="kwh04" value="0" type="hidden">
<input name="kwh05" value="0" type="hidden">
<input name="kwh06" value="0" type="hidden">
<input name="kwh07" value="0" type="hidden">
<input name="kwh08" value="0" type="hidden">
<input name="kwh09" value="0" type="hidden">
<input name="kwh10" value="0" type="hidden">
<input name="kwh11" value="0" type="hidden">
<input name="kwh12" value="0" type="hidden">
<input name="kw01" value="0" type="hidden">
<input name="kw02" value="0" type="hidden">
<input name="kw03" value="0" type="hidden">
<input name="kw04" value="0" type="hidden">
<input name="kw05" value="0" type="hidden">
<input name="kw06" value="0" type="hidden">
<input name="kw07" value="0" type="hidden">
<input name="kw08" value="0" type="hidden">
<input name="kw09" value="0" type="hidden">
<input name="kw10" value="0" type="hidden">
<input name="kw11" value="0" type="hidden">
<input name="kw12" value="0" type="hidden">
<input name="kwhtot" value="0" type="hidden">
<input name="kwhavg" value="0" type="hidden">
<input name="kwtot" value="0" type="hidden">
<input name="rank" value="0" type="hidden">
<input name="mtype" value="1" type="hidden">
<input name="xphase" value="1" type="hidden">
<input name="orate" value="0" type="hidden">
<input name="enddat" value="1309" type="hidden">
</form>
</div>

</div>

<div id="footer" style="width:760px;margin-left:20px;margin-top:10px;">
<hr>
<center><p class="txxsmall">This application is provided as a free service to all members of the Okanogan
County Electric Coop<br>
Copyright January 2012 by Ray Peterson of Pasayten Consulting,
Phone: 425-239-3777, email: pasayten@yahoo.com
</p>
</center></div>
</div>
</body>
</html>

pasayten
Ray Peterson
User avatar
mister_coffee
Posts: 1388
Joined: Thu Jul 16, 2020 7:35 pm
Location: Winthrop, WA
Contact:

Re: www.MethowValley.org

Post by mister_coffee »

Wimps, all wimps here.

Blast from the past, about 22 years ago:

Code: Select all

<?
        include("include/wp2001.php");
        include("include/view_functions.php");
        ob_end_flush();
?>
<FORM action="logsheets.php" method=POST>
<?
        if (ereg("r=([0-9]+),d=(.+)",$QUERY_STRING,$matches)) {
                $where = $matches[1];
                $date = mysqldate_to_wp2001($matches[2]);
                $action = "Update";
                $QUERY_STRING = "";
        }

        if ($where == "") {
                $where = cookiejar("zone");
        } else {
                fill_cookiejar("zone",$where);
        }

        $form = new html_table;
        $form->init(array("rows" => 2, "cols" => 2));
        $form->table_style= 'BORDER="1" CELLPADDING="2" CELLSPACING="2"';

        $form->cell[1][1]["content"] = "Where";
        $form->cell[1][2]["content"] = myselector(
                "SELECT id,name FROM resources WHERE type=$zone_resourcetype AND active<>0 ORDER BY name",
                "where",$where);

        $form->cell[2][1]["content"] = "Date (mm/dd)";
        $form->cell[2][2]["content"] = myfield("date",25,$date);

        $form->code();
        $form->display();
?>
<BR>
        <INPUT type=submit name=action value=Update></INPUT>
        </FORM>
  <HR WIDTH="100%">
<?
        if ($action == "Update" and $where != "") {
                $q  = "SELECT resourcemap.right_resource,resources.name ";
                $q .= "FROM resourcemap,resources ";
                $q .= "WHERE resourcemap.left_resource=$where AND ";
                $q .= "resourcemap.right_resource=resources.id AND ";
                $q .= "resources.type=$camp_resourcetype ";
                $q .= "ORDER BY resourcemap.stacking_order";

                $r1 = wpquery($q);

                $i = 0;
                while ($row = mysql_fetch_row($r1)) {
                        $resources[$i]["id"]   = $row[0];
                        $resources[$i]["name"] = $row[1];
                        ++$i;
                }

                mysql_free_result($r1);

                $extras = extra_resource_data($resources);
                $extra_col = 0;

                for ($i = 0; $i < count($resources); $i++) {
                        $x = $extras[$resources[$i]["id"]];
                        $resources[$i]["extra"] = $x;

                        if (strlen($x) > 0) $extra_col = 1;
                }

                $range = new date_range($date);
                $base = 1;

                $tbl = new html_table;
                $tbl->init(array("rows" => $i + 1, "cols" => 8 + $extra_col));
                $tbl->table_style= 'BORDER="1" CELLPADDING="2" CELLSPACING="2"';

                for ($i = 0; $i < 7; $i++) {
                        $range->span($i);
                        $tm = $range->raw_last();
                        $tbl->cell[1][$extra_col + 2 + $i]["content"] =
                                "<strong>" . date("m/d",$tm) .
                                "</strong>";
                        $tbl->col_style[$extra_col + 2 + $i] = "VALIGN=TOP";
                }

                $range->span(7);

                for ($i = 0; $i < count($resources); $i++) {
                        // make the camp be a link to the camps view on
                        // the appropriate dates...
                        $url_tail = "r=" . $resources[$i]["id"] . ",d=" .
                                $range->mysql_first();

                        $tbl->cell[2 + $i][1]["content"] =
                                "<A HREF=\"camps.php?$url_tail\">" .
                                "<small>" . $resources[$i]["name"] .
                                "</small></A>";

                        if ($extra_col) {
                                $tbl->cell[2 + $i][2]["content"] =
                                        "<small>" .
                                        $resources[$i]["extra"] .
                                        "</small>";
                        }

                        $list = camp_report($range,$resources[$i]["id"],0);

                        for ($j = 0; $j < 7; $j++) {
                                if ($list[$j] == "") continue;
                                $tbl->cell [2+$i][$extra_col+2+$j]["content"] =
                                        "<small>" . $list[$j] . "</small>";
                        }
                }

                $tbl->code();
                $tbl->display();
                print "<HR WIDTH=\"100%\">\n";

        }
?>

<h2>How This Works</h2>

<UL>
<LI>If you don't enter a date, we use the current date.<P>

<LI>You can enter a date with a four-digit year for a year other than
the current one.  There is plenty of data for 1999 and 2000.<P>

<LI>Choose a zone and you'll see all the permits for that zone (by camps)
for the next week.<P>

</UL>

<h2>To Think About</h2>

<UL>
<LI>It got too busy and too ugly when displaying assigned camp sites as well.
Speed might be a concern too.<P>

<LI>Perhaps a variant of this tool that generates a printable form of
the logsheets that could be used in emergencies would be a good idea.<P>

</UL>

</BODY>
</HTML>
More recent work:

Code: Select all

@router.post("/status", response_model=StatusResult)
async def post_status(item: StatusItem):
    """
        posts status from a device, status data is in the json payload

        returns a dict with one entry (ok) set to 1 on success
    """
    # FIXME:  confirm we are posting for the logged-in device
    check_location(item.latitude, item.longitude)
    check_device_id(item.device_id)

    when = time.time()

    if item.status != "GREEN":
        statuses = await get_device_status(item.device_id)
        changed = False

        if statuses is None:
            changed = True
        else:
            status = statuses[0]
            if status["status"] != item.status:
                changed = True

        if changed:
            get_logger().info(f"{item.device_id}:  status changed to {item.status}")
            wps = await find_watchpoints(item.latitude, item.longitude)

            if wps is not None and len(wps) > 0:
                await enqueue_detection(
                    item.status, item.device_id, item.latitude, item.longitude, wps
                )

    """
        FIXME:  there is an optimization here where when there is no image data,
        in that case we can gather both of these futures rather than run them sequentially
    """
    await note_db_status(when, item)
    await note_status(when, item)

    return StatusResult(ok=1)

PHP is freaking ugly.
:arrow: David Bonn :idea:
User avatar
pasayten
Posts: 2444
Joined: Thu Mar 11, 2021 8:03 pm
Contact:

Re: www.MethowValley.org

Post by pasayten »

I have never programmed in Java before but would love to be able to customize the JtyOne Online ZX81 Emulator to be able to save files once created in the emulator.
Can you copy/paste code to a text editor?

Update...

Ahhh... Tried the emulator... can't copy pixel text to save it... lol...

A long time ago, I wrote a great blackjack program for the Z81... wonder where that tape went... :-)
pasayten
Ray Peterson
User avatar
tristanbgilb
Posts: 1048
Joined: Tue Sep 01, 2020 9:20 pm
Contact:

Re: www.MethowValley.org

Post by tristanbgilb »

pasayten wrote: Wed Jan 25, 2023 5:57 pm Need some javascript code on here...

Code: Select all

function getMemberData()
{

//alert("get member data:" + crank);
// Load post arguments
loadpost();
var i = 0;
    kmax = 0.0;
    dmax = 0.0;
for (i = 0; i<12; i++)
{
        if ( isNaN(kary[i]) || kary[i] < 0)
        {
	kary[i] =  0;
	dary[i] =  0;
	nary[i] =  0;
	} else {
	nary[i] = 1;
	if (kary[i] > kmax) kmax = kary[i];
	if (dary[i] > dmax) dmax = dary[i];
	}
        if ( pary[i] < 0) pary[i] = 0;
}
grank = (maxrank - crank) * 100 / maxrank;
grank = Number(grank.toFixed(0));

// Draw the Charts
drawChart4();
fillTable();
drawGage();
calcbill();

}

function loadpost ()
{
document.rateform.kwh01.value = kary[0];
document.rateform.kwh02.value = kary[1];
document.rateform.kwh03.value = kary[2];
document.rateform.kwh04.value = kary[3];
document.rateform.kwh05.value = kary[4];
document.rateform.kwh06.value = kary[5];
document.rateform.kwh07.value = kary[6];
document.rateform.kwh08.value = kary[7];
document.rateform.kwh09.value = kary[8];
document.rateform.kwh10.value = kary[9];
document.rateform.kwh11.value = kary[10];
document.rateform.kwh12.value = kary[11];
document.rateform.kw01.value = dary[0];
document.rateform.kw02.value = dary[1];
document.rateform.kw03.value = dary[2];
document.rateform.kw04.value = dary[3];
document.rateform.kw05.value = dary[4];
document.rateform.kw06.value = dary[5];
document.rateform.kw07.value = dary[6];
document.rateform.kw08.value = dary[7];
document.rateform.kw09.value = dary[8];
document.rateform.kw10.value = dary[9];
document.rateform.kw11.value = dary[10];
document.rateform.kw12.value = dary[11];

document.rateform.xphase.value = phase;
document.rateform.kwhtot.value = totk;
document.rateform.kwhavg.value = kavg;
document.rateform.kwtot.value = totd;
document.rateform.orate.value = origrate;
document.rateform.enddat.value = enddat;
//document.rateform.mrec.value = mrec;
//document.rateform.frec.value = frec;


var sel = document.getElementById('kratex');
for(var i, j = 0; i = sel.options[j]; j++) {
   if(i.value == cur_rate) {
       sel.selectedIndex = j;
       break;
    }
    }
}

function wrtvaln(id,x,z,d)
{
	xx = x;
	if (nary[z] > 0)
	{
	document.getElementById(id).innerHTML = xx.toFixed(d);
	} else {
	document.getElementById(id).innerHTML = "-";
	}
}
function wrtval(id,x,d)
{
	xx = x;
	document.getElementById(id).innerHTML = xx.toFixed(d);
}

function wrpct(id,x,d)
{
	xx = x * 100;
	document.getElementById(id).innerHTML = xx.toFixed(d) + "%";
}
function wrrev(id,x,d)
{
	xx = x;
	//if ( Math.abs(xx) < 1.5 ) xx = 0.0;
	if ( xx < 0) {
	xx = xx * -1.0;
	xx = "($" + AddCom(xx.toFixed(d)) + ")";
	document.getElementById(id).innerHTML = xx;
	} else {
	document.getElementById(id).innerHTML = "$" + AddCom(xx.toFixed(d));
	}
}
function AddCom(nStr)
{
        nStr += '';
        nStr = nStr.replace(/,/g, '');
        x = nStr.split('.');
        x1 = x[0];
        x2 = x.length > 1 ? '.' + x[1] : '';
        var rgx = /(\d+)(\d{3})/;
        while (rgx.test(x1))
        {
            x1 = x1.replace(rgx, '$1' + ',' + '$2');
        }
        return x1 + x2;
}



function drawChart4()
{
var moff = 0;
var xoff = 0;
var leg1 = 'Jan-Dec 2020';
var leg2 = 'Jan-Dec 2021';
if (enddat > 2112) {
xoff = enddat - 2200;
leg1 = mary[xoff] + "2020 - " + mary[xoff+11] + "2021";
leg2 = mary[xoff] + "2021 - " + mary[xoff+11] + "2022";
}

var xdata = google.visualization.arrayToDataTable([
           ['Month', leg1, leg2,'kwh 12 month running avg'],
           [mary[xoff], pary[moff], kary[moff], ravg[moff]],
           [mary[xoff+1], pary[moff+1], kary[moff+1], ravg[moff+1]],
           [mary[xoff+2], pary[moff+2], kary[moff+2], ravg[moff+2]],
           [mary[xoff+3], pary[moff+3], kary[moff+3], ravg[moff+3]],
           [mary[xoff+4], pary[moff+4], kary[moff+4], ravg[moff+4]],
           [mary[xoff+5], pary[moff+5], kary[moff+5], ravg[moff+5]],
           [mary[xoff+6], pary[moff+6], kary[moff+6], ravg[moff+6]],
           [mary[xoff+7], pary[moff+7], kary[moff+7], ravg[moff+7]],
           [mary[xoff+8], pary[moff+8], kary[moff+8], ravg[moff+8]],
           [mary[xoff+9], pary[moff+9], kary[moff+9], ravg[moff+9]],
           [mary[xoff+10], pary[moff+10], kary[moff+10], ravg[moff+10]],
           [mary[xoff+11], pary[moff+11], kary[moff+11], ravg[moff+11]]
         ]);


var chart = new google.visualization.ComboChart(document.getElementById('chart_div'));
var options = {
  width: 580, height: 320,
  vAxis: {title: 'kwh used', titleTextStyle: {color: 'black', fontSize: 16 }},
  pointSize: 6,
  chartArea: {width: "87%", left: 60, height: "90%", top:15},
  seriesType: "bars",
  legend: {position: 'in', textStyle: {color: 'black', fontSize: 12}},
  series: [{type: 'bars', color: '#F88017'},{type: 'bars', color: 'Blue'},{type: 'line', color: '#800517'}]
  };

 chart.draw(xdata, options);
}




function fillTable()
{

var moff = 0;
var xxg = "G";
var yr1 = " 2021";
var yr2 = " 2021";
if (enddat > 2112) {
moff = enddat - 2200;
yr2 = " 2022";
}
document.getElementById('m1').innerHTML = mary[moff] + yr1;
document.getElementById('m2').innerHTML = mary[moff+1];
document.getElementById('m3').innerHTML = mary[moff+2];
document.getElementById('m4').innerHTML = mary[moff+3];
document.getElementById('m5').innerHTML = mary[moff+4];
document.getElementById('m6').innerHTML = mary[moff+5];
document.getElementById('m7').innerHTML = mary[moff+6];
document.getElementById('m8').innerHTML = mary[moff+7];
document.getElementById('m9').innerHTML = mary[moff+8];
document.getElementById('m10').innerHTML = mary[moff+9];
document.getElementById('m11').innerHTML = mary[moff+10];
document.getElementById('m12').innerHTML = mary[moff+11] + yr2;
wrtvaln('k1',kary[0],0,0);
wrtvaln('k2',kary[1],1.0);
wrtvaln('k3',kary[2],2,0);
wrtvaln('k4',kary[3],3,0);
wrtvaln('k5',kary[4],4,0);
wrtvaln('k6',kary[5],5,0);
wrtvaln('k7',kary[6],6,0);
wrtvaln('k8',kary[7],7,0);
wrtvaln('k9',kary[8],8,0);
wrtvaln('k10',kary[9],9,0);
wrtvaln('k11',kary[10],10,0);
wrtvaln('k12',kary[11],11,0);
wrtval('k13',totk,0);
wrtval('tkwh',totk,0);
wrtval('mxkwh',kmax,0);
wrtval('mavg',kavg,1);
wrtval('krank',crank,0);
wrtval('grk',grank,0);

xxr = 0;
if (cur_rate == 50) xxr = 1;
if (cur_rate == 51) xxr = 2;
if (cur_rate == 52) xxr = 3;
if (cur_rate == 53) xxr = 4;
xxg = "2021 G" + xxr + " Rate";
if (cur_rate == 54) {
	xxr = "Irrig 1P";
	xxg = "2021 Irr1P Rate";
    newcls = "Irrig 1P";
    document.getElementById('ratecd').innerHTML = "5";
}
if (cur_rate == 55) {
	xxr = "Irrig 3P";
	xxg = "2021 Irr3P Rate";
    newcls = "Irrig 3P";
    document.getElementById('ratecd').innerHTML = "6";
}
document.getElementById('newgx').innerHTML = newcls;
document.getElementById('currate').innerHTML = xxr;
//alert(xxg);
document.getElementById('g2015').innerHTML = xxg;

// set member id
document.getElementById('mrec').innerHTML = mrec;
document.getElementById('frec').innerHTML = frec;




// Logic to figure if acceptable class/rate
if ( cur_rate < 54 ) {
  if ( kavg > 16666.0 ) {
  document.getElementById('ratecd').innerHTML = "4";
  } else if ( kavg > 5000.0 ) {
  document.getElementById('ratecd').innerHTML = "3";
  } else if ( kavg > 1200.0 ) {
  document.getElementById('ratecd').innerHTML = "2";
  }
}
// Logic to figure if class/rate OK
// rate g1... class g3/g3
if ( cur_rate == 50 && kavg > 1200.0 ) {
document.getElementById('classchg').innerHTML = "exceeds the limit for Class G1 and you may be changed to Class G2";
}
// rate g2 and class g3
if ( cur_rate == 51 && kavg > 5000.0 ) {
document.getElementById('classchg').innerHTML = "exceeds the limit for Class G2 and you may be changed to Class G3";
}
if ( cur_rate == 56 && kavg > 5000.0 ) {
document.getElementById('classchg').innerHTML = "exceeds the limit for Class G3 and you may be changed to Class G4";
}
// rate g2... class g1
if ( cur_rate == 51 && kavg <= 1200.0 ) {
document.getElementById('classchg').innerHTML = "is less than minimums for Class G2 and you may reduce to Class G1";
}
// rate g2... class g1
if ( cur_rate == 52 && kavg <= 5000.0 ) {
document.getElementById('classchg').innerHTML = "is less than minimums for Class G3 and you may reduce to Class G2";
}
// rate g2... class g1
if ( cur_rate == 53 && kavg <= 16667.0 ) {
document.getElementById('classchg').innerHTML = "is less than minimums for Class G4 and you may reduce to Class G3";
}


wrtvaln('kw1',dary[0],0,2);
wrtvaln('kw2',dary[1],1,2);
wrtvaln('kw3',dary[2],2,2);
wrtvaln('kw4',dary[3],3,2);
wrtvaln('kw5',dary[4],4,2);
wrtvaln('kw6',dary[5],5,2);
wrtvaln('kw7',dary[6],6,2);
wrtvaln('kw8',dary[7],7,2);
wrtvaln('kw9',dary[8],8,2);
wrtvaln('kw10',dary[9],9,2);
wrtvaln('kw11',dary[10],10,2);
wrtvaln('kw12',dary[11],11,2);
//wrtval('kw13',totd,2);
wrtval('mxkw',dmax,2);


}


function drawGage()
{
   var zdata = new google.visualization.DataTable();
   zdata.addColumn('string', 'Label');
   zdata.addColumn('number', 'Value');
   zdata.addRows([
    ['kwh rank', grank]
   ]);
    var options = {
     width: 150, height: 150,
     yellowFrom:60, yellowTo: 100,
     minorTicks: 5
   };
    var chart = new google.visualization.Gauge(document.getElementById('gage_div'));
   chart.draw(zdata, options);
}

function calcrate (rate,docur)
{

var kfac = 1.0;
var kbase1 = 0.0;
var kbase3 = 0.0;
var kbase = 0.0;
var kener = 0.0;
var kdinc = 0.0;
var xt1 = 0;
var xt2 = 0;
var xt3 = 0;
var krate1 = 0.0;
var krate2 = 0.0;
var krate3 = 0.0;
var kopa = 0.0;
var kdem = 0.0;
var zkwh = 0.0;
var xdem = 0.0;
pbill = 0.0;

// Okanogan PUD
if (rate == 1)
{
kbase1 = 39.95;
kener = 0.0;
//xt1 = 500;
//xt2 = 2000;
xt2 = 2000;
krate1 = 0.05441;
krate2 = 0.07019;
kopa = 0.0000;
document.getElementById('pcomp').innerHTML = "Okanogan PUD rate 2021";
}

// Okanogan PUD
if (rate == 2)
{
kbase1 = 42.00;
kener = 0.0;
//xt1 = 500;
//xt2 = 2000;
xt2 = 2000;
krate1 = 0.05824;
krate2 = 0.06989;
kopa = 0.0000;
document.getElementById('pcomp').innerHTML = "Okanogan PUD rate Apr 2023";
}

// Orcas Coop
if (rate == 3)
{
kbase1 = 50.35;
xt2 = 4000;
krate1 = 0.1133;
krate2 = 0.1284;
xt3 = 5000;
krate3 = 0.1478;
kopa = 0.00079;
document.getElementById('pcomp').innerHTML = "OPALCO (Island County) winter rate";
}

// Colville
if (rate == 4)
{
kbase1 = 9.00;
xt2 = 800;
xt3 = 1500;
krate1 = 0.08519;
krate2 = 0.09911;
krate3 = 0.11621;
kfac = 1.06;
document.getElementById('pcomp').innerHTML = "Colville (Avista) rate";
}

// Oregon Trail
if (rate == 5)
{
kbase1 = 33.50;
krate1 = 0.06797;
kopa = 0.00000;
document.getElementById('pcomp').innerHTML = "Oregon Trail rate";
}
// Northern Lites
if (rate == 6)
{
kbase1 = 30.00;
xt2 = 1250;
krate1 = 0.08230;
krate2 = 0.10280;
document.getElementById('pcomp').innerHTML = "Northern Lights (Montana) rate";
}
// Western Oregon
if (rate == 7)
{
kbase1 = 52.00;
xt2 = 1500;
//xt3 = 1200;
krate1 = 0.16930;
krate2 = 0.13410;
//krate3 = 0.0890;
document.getElementById('pcomp').innerHTML = "Western Oregon Coop rate";
}

// Umatilla
if (rate == 200)
{
kbase1 = 22.00;
//xt2 = 1800;
krate1 = 0.0733;
//krate2 = 0.0800;
document.getElementById('pcomp').innerHTML = "Umatilla Electric Winter rate";
}

// Puget Sound Energy
if (rate == 301)
{
kbase1 = 7.49;
xt2 = 600;
krate1 = 0.08593;
krate2 = 0.10490;
document.getElementById('pcomp').innerHTML = "Puget Sound Energy rate";
}

// Tanner Electric
if (rate == 8)
{
kbase1 = 39.83;
krate1 = 0.0998;
document.getElementById('pcomp').innerHTML = "Tanner Electric rate";
}

// Nespelum Electric
if (rate == 9)
{
kbase1 = 23.50;
krate1 = 0.07690;
document.getElementById('pcomp').innerHTML = "Nespelem Electric rate";
}

// Inland Power
if (rate == 11)
{
kbase1 = 24.55;
krate1 = 0.0680;
document.getElementById('pcomp').innerHTML = "Inland Electric rate";
}

// Lakeview Power
if (rate == 91)
{
kbase1 = 25.00;
krate1 = 0.0750;
document.getElementById('pcomp').innerHTML = "Lakeview Electric rate";
}

// Sno county pud
if (rate == 10)
{
kbase1 = 57.00;
krate1 = 0.10174;
document.getElementById('pcomp').innerHTML = "Snohomish County PUD rate";
}


// Ferry Power
if (rate == 12)
{
kbase1 = 20.00;
krate1 = 0.08798;
document.getElementById('pcomp').innerHTML = "Ferry Power rate";
}


// glacier electric
if (rate == 13)
{
kbase1 = 25.00;
krate1 = 0.0725;
document.getElementById('pcomp').innerHTML = "Glacier Electric (Montana) rate";
}

// Chelan PUD
if (rate == 15)
{
kbase1 = 12.95;
krate1 = 0.0270;
document.getElementById('pcomp').innerHTML = "Chelan PUD residential rate";
}


// Parkland
if (rate == 17)
{
kbase1 = 20.00;
krate1 = 0.0671;
document.getElementById('pcomp').innerHTML = "Parkland Light Coop rate";
}

// Big Bend
if (rate == 18)
{
kbase1 = 28.00;
krate1 = 0.06640;
document.getElementById('pcomp').innerHTML = "Big Bend	 rate";
}

// Kittitas PUD
if (rate == 19)
{
kbase1 = 25.50;
krate1 = 0.0982;
document.getElementById('pcomp').innerHTML = "Kittitas PUD rate";
}

// Skamania
if (rate == 20)
{
kbase1 = 47.00;
krate1 = 0.0929;
document.getElementById('pcomp').innerHTML = "Skamania PUD rate";
}

// Pend Oreille
if (rate == 21)
{
kbase1 = 35.50;
krate1 = 0.0623;
document.getElementById('pcomp').innerHTML = "Pend Oreille PUD rate";
}

// Columbia REA
if (rate == 22)
{
kbase1 = 35.00;
krate1 = 0.0902;
document.getElementById('pcomp').innerHTML = "Columbia REA rate";
}


// Seattle
if (rate == 25)
{
kbase1 = 5.06;
xt2 = 480;
krate1 = 0.0780;
krate2 = 0.1326;
document.getElementById('pcomp').innerHTML = "Seattle rate";
}


// Tacoma
if (rate == 26)
{
kbase1 = 16.50;
krate1 = 0.079786;
document.getElementById('pcomp').innerHTML = "Tacoma rate";
}



// Old OCEC
if (rate == 23)
{
kbase1 = 29.00;
xt2 = 1400;
krate1 = 0.048;
krate2 = 0.058;
document.getElementById('pcomp').innerHTML = "OCEC 2006 rate";
}

// General 1 rate
if (rate == 181)
{
kbase1 = 32.00;
kdem = 0.0;
krate1 = 0.081;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Gen Service 1 Rate (1)";
}

// General 2 rate
if (rate == 182)
{
kbase1 = 50.0;
kdem = 0.0;
krate1 = 0.0678;
xt2 = 5000;
krate2 = 0.0758;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Gen Service 2 Rate (2)";
}

// General 3 rate
if (rate == 183)
{
kbase1 = 60.0;
kdem = 3.25
krate1 = 0.0493;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Gen Service 3 Rate (3)";
}

// General 4 rate
if (rate == 184)
{
kbase1 = 145.0;
kdem = 3.25;
krate1 = 0.0477;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Gen Service 4 Rate (4)";
}


// General Irr 1P rate
if (rate == 185)
{
kbase1 = 46.0;
kdem = 3.25;
krate1 = 0.04950;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Irrigation 1P Rate (5)";
}
// General Irr 3P rate
if (rate == 186)
{
kbase1 = 59.0;
kdem = 3.25;
krate1 = 0.04950;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Irrigation 3P Rate (6)";
}

// General 1 rate
if (rate == 191)
{
kbase1 = 32.00;
kdem = 0.0;
krate1 = 0.0836;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Gen Service 1 Rate (1)";
}

// General 2 rate
if (rate == 192)
{
kbase1 = 50.0;
kdem = 0.0;
krate1 = 0.0704;
xt2 = 5000;
krate2 = 0.0784;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Gen Service 2 Rate (2)";
}

// General 3 rate
if (rate == 193)
{
kbase1 = 60.0;
kdem = 3.50
krate1 = 0.05080;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Gen Service 3 Rate (3)";
}

// General 4 rate
if (rate == 194)
{
kbase1 = 145.0;
kdem = 3.50;
krate1 = 0.0485;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Gen Service 4 Rate (4)";
}


// General Irr 1P rate
if (rate == 195)
{
kbase1 = 46.0;
kdem = 3.50;
krate1 = 0.0508;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Irrigation 1P Rate (5)";
}
// General Irr 3P rate
if (rate == 196)
{
kbase1 = 59.0;
kdem = 3.50;
krate1 = 0.0508;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Irrigation 3P Rate (6)";
}


// General 1 rate
if (rate == 201)
{
kbase1 = 33.60;
kdem = 0.0;
krate1 = 0.0851;
document.getElementById('pcomp').innerHTML = "OCEC Apr 2023 Gen Service 1 Rate(1)";
}

// General 2 rate
if (rate == 202)
{
kbase1 = 52.50;
kdem = 0.0;
krate1 = 0.0712;
xt2 = 5000;
krate2 = 0.0796;
document.getElementById('pcomp').innerHTML = "OCEC Apr 2023 Gen Service 2 Rate(2)";
}

// General 3 rate
if (rate == 203)
{
kbase1 = 63.0;
kdem = 3.40
krate1 = 0.05180;
document.getElementById('pcomp').innerHTML = "OCEC Apr 2023 Gen Service 3 Rate(3)";
}

// General 4 rate
if (rate == 204)
{
kbase1 = 152.25;
kdem = 3.40;
krate1 = 0.0501;
document.getElementById('pcomp').innerHTML = "OCEC Apr 2023 Gen Service 4 Rate(4)";
}


// General Irr 1P rate
if (rate == 205)
{
kbase1 = 48.30;
kdem = 3.40;
krate1 = 0.0520;
document.getElementById('pcomp').innerHTML = "OCEC Apr 2023 Irrig 1P Rate(5)";
}
// General Irr 3P rate
if (rate == 206)
{
kbase1 = 62.0;
kdem = 3.40;
krate1 = 0.0520;
document.getElementById('pcomp').innerHTML = "OCEC Apr 2023 Irrig 3P Rate 6)";
}

if ( kbase3 == 0 ) kbase3 = kbase1;
kbase = kbase1;
if (phase == 3 )
{
kbase = kbase3;
}
wrtval('pbase',kbase1,2);
wrtval('pbase3',kbase3,2);
//wrtval('pener',kener,2);
//wrtval('ptier1',xt1,0);
wrtval('pdem',kdem,2);
wrtval('pdinc',kdinc,0);
wrtval('prate1',krate1,5);
wrtval('prate2',krate2,5);
wrtval('prate3',krate3,5);
wrtval('ptier2',xt2,0);
wrtval('ptier3',xt3,0);
wrtval('pkopa',kopa,4);

if (docur && origrate == 3) alert("Note: Just for your information, you are signed up for the current alternate rate w/o demand. Click to continue");

for (i = 0; i<12;i++)
{
xkwh = kary[i];
xkw = dary[i];
if (docur) crb[i] = 0;

if (nary[i] && docur)
{
if (cur_rate == 50) {
	crb[i] = 32.00 + (xkwh * 0.081);
	//if (xkwh > 1200) crb[i] = crb[i] + (xkwh -1200) * 0.006;
}
//alert("currate:" + cur_rate);
if (cur_rate == 51) {
	crb[i] = 50.0 + (xkwh * 0.0678);
	if (xkwh > 5000) crb[i] = crb[i] + (xkwh -5000) * 0.008;
}
if (cur_rate == 52) crb[i] = 60.0 + (xkwh * 0.0493) + (xkw * 3.25);
if (cur_rate == 53) crb[i] = 145.0 + (xkwh * 0.0477) + (xkw * 3.25);
if (cur_rate == 54) {
   if ( mary[i] == "Oct" ) {
	   crb[i] = (xkwh * 0.0495) + (xkw * 3.25);
       } else {
	   crb[i] = 46.0 + (xkwh * 0.0495) + (xkw * 3.25);
   }
}

if (cur_rate == 55) {
   if ( mary[i] == "Oct" ) {
	   crb[i] = (xkwh * 0.0495) + (xkw * 3.25);
       } else {
	   crb[i] = 59.0 + (xkwh * 0.0495) + (xkw * 3.25);
   }
}
}
// Calc with propsed rate
   zkwh = 0;
   if ( xt3 > 0 )
   	{
   	if (xkwh > xt3)
   		{
   		zkwh = zkwh + (xkwh - xt3) * krate3;
   		xkwh = xt3;
   		}
   	}
   if ( xt2 > 0 )
   	{
	if (xkwh > xt2)
   		{
   		zkwh = zkwh + (xkwh - xt2) * krate2;
   		xkwh = xt2;
   		}
   	}
   // Check for kwh inc = ktier1
   if (xkwh > xt1)
   	{
   	xkwh = xkwh - xt1;
   	} else {
   	xkwh = 0.0;
	}
   zkwh = zkwh + xkwh * krate1;
   if ( kopa > 0 ) zkwh = zkwh + kary[i] * kopa;

// Calc demand rev
   zdem = 0.0;
   if (kdinc > 0)
   {
   		if (xkw > kdinc )
   		{
   		xkw = xkw - kdinc;
   		} else {
   		xkw = 0.0;
   		}
	}
	zdem = xkw * kdem;
if (nary[i])
	{

        if (cur_rate == 55 || cur_rate == 54) {
			if (mary[i] == "Oct") kbase = 0;
		}
     	prb[i] = (kbase + zkwh + zdem + kener) * kfac;
		chb[i] = (prb[i] - crb[i]) / crb[i];
		if (docur) cbill = cbill + crb[i];
		pbill = pbill + prb[i];
	} else {
		prb[i] = 0;
		chb[i] = 0;
	}

}

chgbill = (pbill - cbill) / cbill;

}


function calcbill ()
{
// Put rates in table...

calcrate(cur_rate,1);
wrrev('o1',crb[0],2);
wrrev('o2',crb[1],2);
wrrev('o3',crb[2],2);
wrrev('o4',crb[3],2);
wrrev('o5',crb[4],2);
wrrev('o6',crb[5],2);
wrrev('o7',crb[6],2);
wrrev('o8',crb[7],2);
wrrev('o9',crb[8],2);
wrrev('o10',crb[9],2);
wrrev('o11',crb[10],2);
wrrev('o12',crb[11],2);
wrrev('o13',cbill,2);
wrrev('zold',cbill,2);
}

function newbill ()
{
// Put rates in table...

var xrate = document.rateform.kratex.value;
calcrate(xrate,0);
wrrev('n1',prb[0],2);
wrrev('n2',prb[1],2);
wrrev('n3',prb[2],2);
wrrev('n4',prb[3],2);
wrrev('n5',prb[4],2);
wrrev('n6',prb[5],2);
wrrev('n7',prb[6],2);
wrrev('n8',prb[7],2);
wrrev('n9',prb[8],2);
wrrev('n10',prb[9],2);
wrrev('n11',prb[10],2);
wrrev('n12',prb[11],2);
wrrev('n13',pbill,2);
wrpct('c1',chb[0],1);
wrpct('c2',chb[1],1);
wrpct('c3',chb[2],1);
wrpct('c4',chb[3],1);
wrpct('c5',chb[4],1);
wrpct('c6',chb[5],1);
wrpct('c7',chb[6],1);
wrpct('c8',chb[7],1);
wrpct('c9',chb[8],1);
wrpct('c10',chb[9],1);
wrpct('c11',chb[10],1);
wrpct('c12',chb[11],1);
wrpct('c13',chgbill,1);
wrrev('zold',cbill,2);
wrrev('znew',pbill,2);
xtemp = pbill - cbill;
wrrev('zchg',xtemp,2);
xtemp = (pbill - cbill)/12.0;
wrrev('zchgm',xtemp,2);

}
I have never programmed in Java before but would love to be able to customize the JtyOne Online ZX81 Emulator to be able to save files once created in the emulator.

Code: Select all

/* EightyOne  - A Windows ZX80/81/clone emulator.
 * Copyright (C) 2003-2006 Michael D Wynne
 * Java translation (C) 2006 Simon Holdsworth
 *
 * 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
 * (at your option) 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., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
package jtyone.main;

import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Canvas;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Label;
import java.awt.Panel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import jtyone.config.ZX81Config;
import jtyone.config.ZX81ConfigDefs;
import jtyone.display.AccDraw;
import jtyone.io.KBStatus;
import jtyone.zx81.ZX81;

/**
 * This class allows display of the Jtyone emulator as an application or
 * applet.
 * 
 * @author Simon Holdsworth
 */
public class JtyOne 
extends Applet
implements KeyListener, WindowListener, ActionListener, FocusListener
  {
  private AccDraw mDisplayDrawer;
  private KBStatus mKeyboard;
  private ZX81Config mConfig;
  
  private Canvas mCanvas;
  private Thread mDisplayThread;
  private Button mPauseButton;
  private Button mResetButton;
  private Label mStatusLabel;
  private Label mJtyOneLabel;
  
  /**
   * @param args
   */
  public static 
  void main(String[] args) 
    {
    JtyOne jtyone = new JtyOne();
    Frame f = new Frame("JtyOne Emulator Window");
    jtyone.init(args,f,false);
    // Focus listening is only done for the application. For the applet, that's
    // handled via javascript on the web page.
    f.addWindowListener(jtyone);
    f.addKeyListener(jtyone);
    f.pack();    
    f.setVisible(true);
    jtyone.start();
    }
  
  /** Constructor.
   */
  public
  JtyOne()
    {
    // One-off initialisation.
    mConfig = new ZX81Config();
    mConfig.machine = new ZX81();
    mConfig.load_config();
    mConfig.zx81opts.cwd = ".";
    mConfig.zx81opts.m1not = 32768;
    }
  
  /**
   *  
   */
  public
  void init()
    {
    init(getParameter("tzxFileName"),
         getParameter("hires"),
         getParameter("scale"),
         getParameter("machine"),
         this,true);
    }
  

  /**
   *
   */
  public
  void init(String[] args, Container container, boolean applet )
    {   
    String tzxFileName = (args.length > 0 && !args[0].startsWith("-")) ? args[0] : null;
    String scale = null;
    String hires = null;
    String machine = null;
    
    for( int aPos = tzxFileName == null ? 0 : 1; aPos < args.length; aPos++ )
      {
      if( args[aPos].equals("-scale") && aPos < args.length-1 )
        {
        scale = args[++aPos];    
        }
      if( args[aPos].equals("-hires") && aPos < args.length-1 )
        {
        hires = args[++aPos];    
        }
      if( args[aPos].equals("-machine") && aPos < args.length-1 )
        {
        machine = args[++aPos];    
        }
      }

    init(tzxFileName,hires,scale,machine,container,applet);
    }
  
  /**
   * 
   */
  private
  void init(String tzxFileName, String hires, String scale, String machine, Container container, boolean applet )
    {
    // Sort out any configured options for the emulator.
    if( "ZX80".equals(machine) )
      {
      mConfig.machine.CurRom = mConfig.zx81opts.ROM80;
      mConfig.zx81opts.machine = ZX81ConfigDefs.MACHINEZX80;
      }
    else 
      mConfig.machine.CurRom = mConfig.zx81opts.ROM81;
    
    int scaleCanvas = 2;
    if( scale != null && scale.length() > 0 )
      scaleCanvas = Integer.parseInt(scale);
    
    if( "qs".equals(hires) )
      mConfig.zx81opts.chrgen = ZX81ConfigDefs.CHRGENQS;
    else if( "dk".equals(hires) )
      mConfig.zx81opts.chrgen = ZX81ConfigDefs.CHRGENDK;

    mConfig.machine.initialise(mConfig);

    // Set up keyboard.
    mKeyboard = new KBStatus(mConfig);
    
    // Set up the various components.
    container.setLayout(new BorderLayout());
    container.addKeyListener(this);
    container.addFocusListener(this);
    Panel bottomPanel = new Panel();
    bottomPanel.setLayout(new BorderLayout());
    container.add(bottomPanel,"South");
    Panel buttonPanel = new Panel();
    buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT,0,0));
    bottomPanel.add(buttonPanel,"East");
    mPauseButton = new Button("Pause");
    mPauseButton.addActionListener(this);
    buttonPanel.add(mPauseButton);
    mResetButton = new Button("Reset");
    mResetButton.addActionListener(this);
    buttonPanel.add(mResetButton);
    mStatusLabel = new Label("status");
    bottomPanel.add(mStatusLabel,"Center");
    mJtyOneLabel = new Label("JtyOne");
    bottomPanel.add(mJtyOneLabel,"West");

    // Set up the display.
    mDisplayDrawer = new AccDraw(mConfig,mStatusLabel,false,scaleCanvas);
    mCanvas = mDisplayDrawer.getCanvas();
    mCanvas.addFocusListener(this);
    mCanvas.addKeyListener(this);
    container.add(mCanvas,"Center");

    // Load the .TZX file.
    try 
      {
      if( tzxFileName != null )
        {
        String tzxEntry = null;
        int entryNum = 0;
        int atPos = tzxFileName.indexOf('@');
        if( atPos != -1 )
          {
          tzxEntry = tzxFileName.substring(atPos+1);
          tzxFileName = tzxFileName.substring(0,atPos);
          entryNum = Integer.parseInt(tzxEntry);
          }

        mConfig.machine.getTape().loadTZX(mConfig,mKeyboard,tzxFileName,entryNum,applet);
        }
      }
    catch( Exception exc )
      {
      System.out.println("Error: "+exc);
      exc.printStackTrace();
      }
    }

  public
  void start()
    {   
    mCanvas.requestFocus();
    mDisplayThread = new Thread(mDisplayDrawer);
    mDisplayThread.start();           
    }

  /**Stops the applet.
   */
  public void
  stop()
    {
    mDisplayDrawer.stop();
    mDisplayThread.stop();
    mDisplayThread = null;
    }
  
  public void keyPressed(KeyEvent e)
    {
    mKeyboard.PCKeyDown(e.getKeyCode());
    }
  
  public void keyReleased(KeyEvent e) 
    {
    mKeyboard.PCKeyUp(e.getKeyCode());
    }
  
  public void keyTyped(KeyEvent e) 
    {
    }
  
  public void windowOpened(WindowEvent e) { }

  public void windowClosing(WindowEvent e) 
    { 
    stop();
    System.exit(0);
    }

  public void windowClosed(WindowEvent e) 
    { 
    }

  public void windowIconified(WindowEvent e) { }

  public void windowDeiconified(WindowEvent e) { }

  public void windowActivated(WindowEvent e) { }

  public void windowDeactivated(WindowEvent e) { }
  
  public void actionPerformed(ActionEvent e) 
    {
    if( e.getSource() instanceof Button )
      {
      Button button = (Button)e.getSource();
      if( button.getLabel().equals("Pause") )
        windowActive(false);
      else if( button.getLabel().equals("Start") )
        windowActive(true);
      else if( button.getLabel().equals("Reset") )
        {
        mConfig.machine.initialise(mConfig);
        mCanvas.requestFocus();
        windowActive(true);
        }
      }
    }

  public void windowActive(boolean active)
    {
    mDisplayDrawer.setPaused(!active);
    mPauseButton.setLabel(active?"Pause":"Start");
    }

  public void focusGained(FocusEvent e) 
    {
    windowActive(true);
    }

  public void focusLost(FocusEvent e) 
    {
    if( e.getOppositeComponent() != mPauseButton &&
        e.getOppositeComponent() != mResetButton &&
        e.getOppositeComponent() != mCanvas )
      windowActive(false);
    }    
  }
The entire emulator source is available for download here. http://www.zx81stuff.org.uk/zx81/JtyOne.1.3.src.zip
I love this ZX81 emulator only I would also like to be able to load programs in from a text file.
Image

Image <=NUCLEAR BUTTONImage

Image

KFAC-LP 105.5 FM Twisp WA
User avatar
pasayten
Posts: 2444
Joined: Thu Mar 11, 2021 8:03 pm
Contact:

Re: www.MethowValley.org

Post by pasayten »

Need some javascript code on here...

Code: Select all

function getMemberData()
{

//alert("get member data:" + crank);
// Load post arguments
loadpost();
var i = 0;
    kmax = 0.0;
    dmax = 0.0;
for (i = 0; i<12; i++)
{
        if ( isNaN(kary[i]) || kary[i] < 0)
        {
	kary[i] =  0;
	dary[i] =  0;
	nary[i] =  0;
	} else {
	nary[i] = 1;
	if (kary[i] > kmax) kmax = kary[i];
	if (dary[i] > dmax) dmax = dary[i];
	}
        if ( pary[i] < 0) pary[i] = 0;
}
grank = (maxrank - crank) * 100 / maxrank;
grank = Number(grank.toFixed(0));

// Draw the Charts
drawChart4();
fillTable();
drawGage();
calcbill();

}

function loadpost ()
{
document.rateform.kwh01.value = kary[0];
document.rateform.kwh02.value = kary[1];
document.rateform.kwh03.value = kary[2];
document.rateform.kwh04.value = kary[3];
document.rateform.kwh05.value = kary[4];
document.rateform.kwh06.value = kary[5];
document.rateform.kwh07.value = kary[6];
document.rateform.kwh08.value = kary[7];
document.rateform.kwh09.value = kary[8];
document.rateform.kwh10.value = kary[9];
document.rateform.kwh11.value = kary[10];
document.rateform.kwh12.value = kary[11];
document.rateform.kw01.value = dary[0];
document.rateform.kw02.value = dary[1];
document.rateform.kw03.value = dary[2];
document.rateform.kw04.value = dary[3];
document.rateform.kw05.value = dary[4];
document.rateform.kw06.value = dary[5];
document.rateform.kw07.value = dary[6];
document.rateform.kw08.value = dary[7];
document.rateform.kw09.value = dary[8];
document.rateform.kw10.value = dary[9];
document.rateform.kw11.value = dary[10];
document.rateform.kw12.value = dary[11];

document.rateform.xphase.value = phase;
document.rateform.kwhtot.value = totk;
document.rateform.kwhavg.value = kavg;
document.rateform.kwtot.value = totd;
document.rateform.orate.value = origrate;
document.rateform.enddat.value = enddat;
//document.rateform.mrec.value = mrec;
//document.rateform.frec.value = frec;


var sel = document.getElementById('kratex');
for(var i, j = 0; i = sel.options[j]; j++) {
   if(i.value == cur_rate) {
       sel.selectedIndex = j;
       break;
    }
    }
}

function wrtvaln(id,x,z,d)
{
	xx = x;
	if (nary[z] > 0)
	{
	document.getElementById(id).innerHTML = xx.toFixed(d);
	} else {
	document.getElementById(id).innerHTML = "-";
	}
}
function wrtval(id,x,d)
{
	xx = x;
	document.getElementById(id).innerHTML = xx.toFixed(d);
}

function wrpct(id,x,d)
{
	xx = x * 100;
	document.getElementById(id).innerHTML = xx.toFixed(d) + "%";
}
function wrrev(id,x,d)
{
	xx = x;
	//if ( Math.abs(xx) < 1.5 ) xx = 0.0;
	if ( xx < 0) {
	xx = xx * -1.0;
	xx = "($" + AddCom(xx.toFixed(d)) + ")";
	document.getElementById(id).innerHTML = xx;
	} else {
	document.getElementById(id).innerHTML = "$" + AddCom(xx.toFixed(d));
	}
}
function AddCom(nStr)
{
        nStr += '';
        nStr = nStr.replace(/,/g, '');
        x = nStr.split('.');
        x1 = x[0];
        x2 = x.length > 1 ? '.' + x[1] : '';
        var rgx = /(\d+)(\d{3})/;
        while (rgx.test(x1))
        {
            x1 = x1.replace(rgx, '$1' + ',' + '$2');
        }
        return x1 + x2;
}



function drawChart4()
{
var moff = 0;
var xoff = 0;
var leg1 = 'Jan-Dec 2020';
var leg2 = 'Jan-Dec 2021';
if (enddat > 2112) {
xoff = enddat - 2200;
leg1 = mary[xoff] + "2020 - " + mary[xoff+11] + "2021";
leg2 = mary[xoff] + "2021 - " + mary[xoff+11] + "2022";
}

var xdata = google.visualization.arrayToDataTable([
           ['Month', leg1, leg2,'kwh 12 month running avg'],
           [mary[xoff], pary[moff], kary[moff], ravg[moff]],
           [mary[xoff+1], pary[moff+1], kary[moff+1], ravg[moff+1]],
           [mary[xoff+2], pary[moff+2], kary[moff+2], ravg[moff+2]],
           [mary[xoff+3], pary[moff+3], kary[moff+3], ravg[moff+3]],
           [mary[xoff+4], pary[moff+4], kary[moff+4], ravg[moff+4]],
           [mary[xoff+5], pary[moff+5], kary[moff+5], ravg[moff+5]],
           [mary[xoff+6], pary[moff+6], kary[moff+6], ravg[moff+6]],
           [mary[xoff+7], pary[moff+7], kary[moff+7], ravg[moff+7]],
           [mary[xoff+8], pary[moff+8], kary[moff+8], ravg[moff+8]],
           [mary[xoff+9], pary[moff+9], kary[moff+9], ravg[moff+9]],
           [mary[xoff+10], pary[moff+10], kary[moff+10], ravg[moff+10]],
           [mary[xoff+11], pary[moff+11], kary[moff+11], ravg[moff+11]]
         ]);


var chart = new google.visualization.ComboChart(document.getElementById('chart_div'));
var options = {
  width: 580, height: 320,
  vAxis: {title: 'kwh used', titleTextStyle: {color: 'black', fontSize: 16 }},
  pointSize: 6,
  chartArea: {width: "87%", left: 60, height: "90%", top:15},
  seriesType: "bars",
  legend: {position: 'in', textStyle: {color: 'black', fontSize: 12}},
  series: [{type: 'bars', color: '#F88017'},{type: 'bars', color: 'Blue'},{type: 'line', color: '#800517'}]
  };

 chart.draw(xdata, options);
}




function fillTable()
{

var moff = 0;
var xxg = "G";
var yr1 = " 2021";
var yr2 = " 2021";
if (enddat > 2112) {
moff = enddat - 2200;
yr2 = " 2022";
}
document.getElementById('m1').innerHTML = mary[moff] + yr1;
document.getElementById('m2').innerHTML = mary[moff+1];
document.getElementById('m3').innerHTML = mary[moff+2];
document.getElementById('m4').innerHTML = mary[moff+3];
document.getElementById('m5').innerHTML = mary[moff+4];
document.getElementById('m6').innerHTML = mary[moff+5];
document.getElementById('m7').innerHTML = mary[moff+6];
document.getElementById('m8').innerHTML = mary[moff+7];
document.getElementById('m9').innerHTML = mary[moff+8];
document.getElementById('m10').innerHTML = mary[moff+9];
document.getElementById('m11').innerHTML = mary[moff+10];
document.getElementById('m12').innerHTML = mary[moff+11] + yr2;
wrtvaln('k1',kary[0],0,0);
wrtvaln('k2',kary[1],1.0);
wrtvaln('k3',kary[2],2,0);
wrtvaln('k4',kary[3],3,0);
wrtvaln('k5',kary[4],4,0);
wrtvaln('k6',kary[5],5,0);
wrtvaln('k7',kary[6],6,0);
wrtvaln('k8',kary[7],7,0);
wrtvaln('k9',kary[8],8,0);
wrtvaln('k10',kary[9],9,0);
wrtvaln('k11',kary[10],10,0);
wrtvaln('k12',kary[11],11,0);
wrtval('k13',totk,0);
wrtval('tkwh',totk,0);
wrtval('mxkwh',kmax,0);
wrtval('mavg',kavg,1);
wrtval('krank',crank,0);
wrtval('grk',grank,0);

xxr = 0;
if (cur_rate == 50) xxr = 1;
if (cur_rate == 51) xxr = 2;
if (cur_rate == 52) xxr = 3;
if (cur_rate == 53) xxr = 4;
xxg = "2021 G" + xxr + " Rate";
if (cur_rate == 54) {
	xxr = "Irrig 1P";
	xxg = "2021 Irr1P Rate";
    newcls = "Irrig 1P";
    document.getElementById('ratecd').innerHTML = "5";
}
if (cur_rate == 55) {
	xxr = "Irrig 3P";
	xxg = "2021 Irr3P Rate";
    newcls = "Irrig 3P";
    document.getElementById('ratecd').innerHTML = "6";
}
document.getElementById('newgx').innerHTML = newcls;
document.getElementById('currate').innerHTML = xxr;
//alert(xxg);
document.getElementById('g2015').innerHTML = xxg;

// set member id
document.getElementById('mrec').innerHTML = mrec;
document.getElementById('frec').innerHTML = frec;




// Logic to figure if acceptable class/rate
if ( cur_rate < 54 ) {
  if ( kavg > 16666.0 ) {
  document.getElementById('ratecd').innerHTML = "4";
  } else if ( kavg > 5000.0 ) {
  document.getElementById('ratecd').innerHTML = "3";
  } else if ( kavg > 1200.0 ) {
  document.getElementById('ratecd').innerHTML = "2";
  }
}
// Logic to figure if class/rate OK
// rate g1... class g3/g3
if ( cur_rate == 50 && kavg > 1200.0 ) {
document.getElementById('classchg').innerHTML = "exceeds the limit for Class G1 and you may be changed to Class G2";
}
// rate g2 and class g3
if ( cur_rate == 51 && kavg > 5000.0 ) {
document.getElementById('classchg').innerHTML = "exceeds the limit for Class G2 and you may be changed to Class G3";
}
if ( cur_rate == 56 && kavg > 5000.0 ) {
document.getElementById('classchg').innerHTML = "exceeds the limit for Class G3 and you may be changed to Class G4";
}
// rate g2... class g1
if ( cur_rate == 51 && kavg <= 1200.0 ) {
document.getElementById('classchg').innerHTML = "is less than minimums for Class G2 and you may reduce to Class G1";
}
// rate g2... class g1
if ( cur_rate == 52 && kavg <= 5000.0 ) {
document.getElementById('classchg').innerHTML = "is less than minimums for Class G3 and you may reduce to Class G2";
}
// rate g2... class g1
if ( cur_rate == 53 && kavg <= 16667.0 ) {
document.getElementById('classchg').innerHTML = "is less than minimums for Class G4 and you may reduce to Class G3";
}


wrtvaln('kw1',dary[0],0,2);
wrtvaln('kw2',dary[1],1,2);
wrtvaln('kw3',dary[2],2,2);
wrtvaln('kw4',dary[3],3,2);
wrtvaln('kw5',dary[4],4,2);
wrtvaln('kw6',dary[5],5,2);
wrtvaln('kw7',dary[6],6,2);
wrtvaln('kw8',dary[7],7,2);
wrtvaln('kw9',dary[8],8,2);
wrtvaln('kw10',dary[9],9,2);
wrtvaln('kw11',dary[10],10,2);
wrtvaln('kw12',dary[11],11,2);
//wrtval('kw13',totd,2);
wrtval('mxkw',dmax,2);


}


function drawGage()
{
   var zdata = new google.visualization.DataTable();
   zdata.addColumn('string', 'Label');
   zdata.addColumn('number', 'Value');
   zdata.addRows([
    ['kwh rank', grank]
   ]);
    var options = {
     width: 150, height: 150,
     yellowFrom:60, yellowTo: 100,
     minorTicks: 5
   };
    var chart = new google.visualization.Gauge(document.getElementById('gage_div'));
   chart.draw(zdata, options);
}

function calcrate (rate,docur)
{

var kfac = 1.0;
var kbase1 = 0.0;
var kbase3 = 0.0;
var kbase = 0.0;
var kener = 0.0;
var kdinc = 0.0;
var xt1 = 0;
var xt2 = 0;
var xt3 = 0;
var krate1 = 0.0;
var krate2 = 0.0;
var krate3 = 0.0;
var kopa = 0.0;
var kdem = 0.0;
var zkwh = 0.0;
var xdem = 0.0;
pbill = 0.0;

// Okanogan PUD
if (rate == 1)
{
kbase1 = 39.95;
kener = 0.0;
//xt1 = 500;
//xt2 = 2000;
xt2 = 2000;
krate1 = 0.05441;
krate2 = 0.07019;
kopa = 0.0000;
document.getElementById('pcomp').innerHTML = "Okanogan PUD rate 2021";
}

// Okanogan PUD
if (rate == 2)
{
kbase1 = 42.00;
kener = 0.0;
//xt1 = 500;
//xt2 = 2000;
xt2 = 2000;
krate1 = 0.05824;
krate2 = 0.06989;
kopa = 0.0000;
document.getElementById('pcomp').innerHTML = "Okanogan PUD rate Apr 2023";
}

// Orcas Coop
if (rate == 3)
{
kbase1 = 50.35;
xt2 = 4000;
krate1 = 0.1133;
krate2 = 0.1284;
xt3 = 5000;
krate3 = 0.1478;
kopa = 0.00079;
document.getElementById('pcomp').innerHTML = "OPALCO (Island County) winter rate";
}

// Colville
if (rate == 4)
{
kbase1 = 9.00;
xt2 = 800;
xt3 = 1500;
krate1 = 0.08519;
krate2 = 0.09911;
krate3 = 0.11621;
kfac = 1.06;
document.getElementById('pcomp').innerHTML = "Colville (Avista) rate";
}

// Oregon Trail
if (rate == 5)
{
kbase1 = 33.50;
krate1 = 0.06797;
kopa = 0.00000;
document.getElementById('pcomp').innerHTML = "Oregon Trail rate";
}
// Northern Lites
if (rate == 6)
{
kbase1 = 30.00;
xt2 = 1250;
krate1 = 0.08230;
krate2 = 0.10280;
document.getElementById('pcomp').innerHTML = "Northern Lights (Montana) rate";
}
// Western Oregon
if (rate == 7)
{
kbase1 = 52.00;
xt2 = 1500;
//xt3 = 1200;
krate1 = 0.16930;
krate2 = 0.13410;
//krate3 = 0.0890;
document.getElementById('pcomp').innerHTML = "Western Oregon Coop rate";
}

// Umatilla
if (rate == 200)
{
kbase1 = 22.00;
//xt2 = 1800;
krate1 = 0.0733;
//krate2 = 0.0800;
document.getElementById('pcomp').innerHTML = "Umatilla Electric Winter rate";
}

// Puget Sound Energy
if (rate == 301)
{
kbase1 = 7.49;
xt2 = 600;
krate1 = 0.08593;
krate2 = 0.10490;
document.getElementById('pcomp').innerHTML = "Puget Sound Energy rate";
}

// Tanner Electric
if (rate == 8)
{
kbase1 = 39.83;
krate1 = 0.0998;
document.getElementById('pcomp').innerHTML = "Tanner Electric rate";
}

// Nespelum Electric
if (rate == 9)
{
kbase1 = 23.50;
krate1 = 0.07690;
document.getElementById('pcomp').innerHTML = "Nespelem Electric rate";
}

// Inland Power
if (rate == 11)
{
kbase1 = 24.55;
krate1 = 0.0680;
document.getElementById('pcomp').innerHTML = "Inland Electric rate";
}

// Lakeview Power
if (rate == 91)
{
kbase1 = 25.00;
krate1 = 0.0750;
document.getElementById('pcomp').innerHTML = "Lakeview Electric rate";
}

// Sno county pud
if (rate == 10)
{
kbase1 = 57.00;
krate1 = 0.10174;
document.getElementById('pcomp').innerHTML = "Snohomish County PUD rate";
}


// Ferry Power
if (rate == 12)
{
kbase1 = 20.00;
krate1 = 0.08798;
document.getElementById('pcomp').innerHTML = "Ferry Power rate";
}


// glacier electric
if (rate == 13)
{
kbase1 = 25.00;
krate1 = 0.0725;
document.getElementById('pcomp').innerHTML = "Glacier Electric (Montana) rate";
}

// Chelan PUD
if (rate == 15)
{
kbase1 = 12.95;
krate1 = 0.0270;
document.getElementById('pcomp').innerHTML = "Chelan PUD residential rate";
}


// Parkland
if (rate == 17)
{
kbase1 = 20.00;
krate1 = 0.0671;
document.getElementById('pcomp').innerHTML = "Parkland Light Coop rate";
}

// Big Bend
if (rate == 18)
{
kbase1 = 28.00;
krate1 = 0.06640;
document.getElementById('pcomp').innerHTML = "Big Bend	 rate";
}

// Kittitas PUD
if (rate == 19)
{
kbase1 = 25.50;
krate1 = 0.0982;
document.getElementById('pcomp').innerHTML = "Kittitas PUD rate";
}

// Skamania
if (rate == 20)
{
kbase1 = 47.00;
krate1 = 0.0929;
document.getElementById('pcomp').innerHTML = "Skamania PUD rate";
}

// Pend Oreille
if (rate == 21)
{
kbase1 = 35.50;
krate1 = 0.0623;
document.getElementById('pcomp').innerHTML = "Pend Oreille PUD rate";
}

// Columbia REA
if (rate == 22)
{
kbase1 = 35.00;
krate1 = 0.0902;
document.getElementById('pcomp').innerHTML = "Columbia REA rate";
}


// Seattle
if (rate == 25)
{
kbase1 = 5.06;
xt2 = 480;
krate1 = 0.0780;
krate2 = 0.1326;
document.getElementById('pcomp').innerHTML = "Seattle rate";
}


// Tacoma
if (rate == 26)
{
kbase1 = 16.50;
krate1 = 0.079786;
document.getElementById('pcomp').innerHTML = "Tacoma rate";
}



// Old OCEC
if (rate == 23)
{
kbase1 = 29.00;
xt2 = 1400;
krate1 = 0.048;
krate2 = 0.058;
document.getElementById('pcomp').innerHTML = "OCEC 2006 rate";
}

// General 1 rate
if (rate == 181)
{
kbase1 = 32.00;
kdem = 0.0;
krate1 = 0.081;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Gen Service 1 Rate (1)";
}

// General 2 rate
if (rate == 182)
{
kbase1 = 50.0;
kdem = 0.0;
krate1 = 0.0678;
xt2 = 5000;
krate2 = 0.0758;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Gen Service 2 Rate (2)";
}

// General 3 rate
if (rate == 183)
{
kbase1 = 60.0;
kdem = 3.25
krate1 = 0.0493;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Gen Service 3 Rate (3)";
}

// General 4 rate
if (rate == 184)
{
kbase1 = 145.0;
kdem = 3.25;
krate1 = 0.0477;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Gen Service 4 Rate (4)";
}


// General Irr 1P rate
if (rate == 185)
{
kbase1 = 46.0;
kdem = 3.25;
krate1 = 0.04950;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Irrigation 1P Rate (5)";
}
// General Irr 3P rate
if (rate == 186)
{
kbase1 = 59.0;
kdem = 3.25;
krate1 = 0.04950;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Irrigation 3P Rate (6)";
}

// General 1 rate
if (rate == 191)
{
kbase1 = 32.00;
kdem = 0.0;
krate1 = 0.0836;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Gen Service 1 Rate (1)";
}

// General 2 rate
if (rate == 192)
{
kbase1 = 50.0;
kdem = 0.0;
krate1 = 0.0704;
xt2 = 5000;
krate2 = 0.0784;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Gen Service 2 Rate (2)";
}

// General 3 rate
if (rate == 193)
{
kbase1 = 60.0;
kdem = 3.50
krate1 = 0.05080;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Gen Service 3 Rate (3)";
}

// General 4 rate
if (rate == 194)
{
kbase1 = 145.0;
kdem = 3.50;
krate1 = 0.0485;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Gen Service 4 Rate (4)";
}


// General Irr 1P rate
if (rate == 195)
{
kbase1 = 46.0;
kdem = 3.50;
krate1 = 0.0508;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Irrigation 1P Rate (5)";
}
// General Irr 3P rate
if (rate == 196)
{
kbase1 = 59.0;
kdem = 3.50;
krate1 = 0.0508;
document.getElementById('pcomp').innerHTML = "OCEC 2021 Irrigation 3P Rate (6)";
}


// General 1 rate
if (rate == 201)
{
kbase1 = 33.60;
kdem = 0.0;
krate1 = 0.0851;
document.getElementById('pcomp').innerHTML = "OCEC Apr 2023 Gen Service 1 Rate(1)";
}

// General 2 rate
if (rate == 202)
{
kbase1 = 52.50;
kdem = 0.0;
krate1 = 0.0712;
xt2 = 5000;
krate2 = 0.0796;
document.getElementById('pcomp').innerHTML = "OCEC Apr 2023 Gen Service 2 Rate(2)";
}

// General 3 rate
if (rate == 203)
{
kbase1 = 63.0;
kdem = 3.40
krate1 = 0.05180;
document.getElementById('pcomp').innerHTML = "OCEC Apr 2023 Gen Service 3 Rate(3)";
}

// General 4 rate
if (rate == 204)
{
kbase1 = 152.25;
kdem = 3.40;
krate1 = 0.0501;
document.getElementById('pcomp').innerHTML = "OCEC Apr 2023 Gen Service 4 Rate(4)";
}


// General Irr 1P rate
if (rate == 205)
{
kbase1 = 48.30;
kdem = 3.40;
krate1 = 0.0520;
document.getElementById('pcomp').innerHTML = "OCEC Apr 2023 Irrig 1P Rate(5)";
}
// General Irr 3P rate
if (rate == 206)
{
kbase1 = 62.0;
kdem = 3.40;
krate1 = 0.0520;
document.getElementById('pcomp').innerHTML = "OCEC Apr 2023 Irrig 3P Rate 6)";
}

if ( kbase3 == 0 ) kbase3 = kbase1;
kbase = kbase1;
if (phase == 3 )
{
kbase = kbase3;
}
wrtval('pbase',kbase1,2);
wrtval('pbase3',kbase3,2);
//wrtval('pener',kener,2);
//wrtval('ptier1',xt1,0);
wrtval('pdem',kdem,2);
wrtval('pdinc',kdinc,0);
wrtval('prate1',krate1,5);
wrtval('prate2',krate2,5);
wrtval('prate3',krate3,5);
wrtval('ptier2',xt2,0);
wrtval('ptier3',xt3,0);
wrtval('pkopa',kopa,4);

if (docur && origrate == 3) alert("Note: Just for your information, you are signed up for the current alternate rate w/o demand. Click to continue");

for (i = 0; i<12;i++)
{
xkwh = kary[i];
xkw = dary[i];
if (docur) crb[i] = 0;

if (nary[i] && docur)
{
if (cur_rate == 50) {
	crb[i] = 32.00 + (xkwh * 0.081);
	//if (xkwh > 1200) crb[i] = crb[i] + (xkwh -1200) * 0.006;
}
//alert("currate:" + cur_rate);
if (cur_rate == 51) {
	crb[i] = 50.0 + (xkwh * 0.0678);
	if (xkwh > 5000) crb[i] = crb[i] + (xkwh -5000) * 0.008;
}
if (cur_rate == 52) crb[i] = 60.0 + (xkwh * 0.0493) + (xkw * 3.25);
if (cur_rate == 53) crb[i] = 145.0 + (xkwh * 0.0477) + (xkw * 3.25);
if (cur_rate == 54) {
   if ( mary[i] == "Oct" ) {
	   crb[i] = (xkwh * 0.0495) + (xkw * 3.25);
       } else {
	   crb[i] = 46.0 + (xkwh * 0.0495) + (xkw * 3.25);
   }
}

if (cur_rate == 55) {
   if ( mary[i] == "Oct" ) {
	   crb[i] = (xkwh * 0.0495) + (xkw * 3.25);
       } else {
	   crb[i] = 59.0 + (xkwh * 0.0495) + (xkw * 3.25);
   }
}
}
// Calc with propsed rate
   zkwh = 0;
   if ( xt3 > 0 )
   	{
   	if (xkwh > xt3)
   		{
   		zkwh = zkwh + (xkwh - xt3) * krate3;
   		xkwh = xt3;
   		}
   	}
   if ( xt2 > 0 )
   	{
	if (xkwh > xt2)
   		{
   		zkwh = zkwh + (xkwh - xt2) * krate2;
   		xkwh = xt2;
   		}
   	}
   // Check for kwh inc = ktier1
   if (xkwh > xt1)
   	{
   	xkwh = xkwh - xt1;
   	} else {
   	xkwh = 0.0;
	}
   zkwh = zkwh + xkwh * krate1;
   if ( kopa > 0 ) zkwh = zkwh + kary[i] * kopa;

// Calc demand rev
   zdem = 0.0;
   if (kdinc > 0)
   {
   		if (xkw > kdinc )
   		{
   		xkw = xkw - kdinc;
   		} else {
   		xkw = 0.0;
   		}
	}
	zdem = xkw * kdem;
if (nary[i])
	{

        if (cur_rate == 55 || cur_rate == 54) {
			if (mary[i] == "Oct") kbase = 0;
		}
     	prb[i] = (kbase + zkwh + zdem + kener) * kfac;
		chb[i] = (prb[i] - crb[i]) / crb[i];
		if (docur) cbill = cbill + crb[i];
		pbill = pbill + prb[i];
	} else {
		prb[i] = 0;
		chb[i] = 0;
	}

}

chgbill = (pbill - cbill) / cbill;

}


function calcbill ()
{
// Put rates in table...

calcrate(cur_rate,1);
wrrev('o1',crb[0],2);
wrrev('o2',crb[1],2);
wrrev('o3',crb[2],2);
wrrev('o4',crb[3],2);
wrrev('o5',crb[4],2);
wrrev('o6',crb[5],2);
wrrev('o7',crb[6],2);
wrrev('o8',crb[7],2);
wrrev('o9',crb[8],2);
wrrev('o10',crb[9],2);
wrrev('o11',crb[10],2);
wrrev('o12',crb[11],2);
wrrev('o13',cbill,2);
wrrev('zold',cbill,2);
}

function newbill ()
{
// Put rates in table...

var xrate = document.rateform.kratex.value;
calcrate(xrate,0);
wrrev('n1',prb[0],2);
wrrev('n2',prb[1],2);
wrrev('n3',prb[2],2);
wrrev('n4',prb[3],2);
wrrev('n5',prb[4],2);
wrrev('n6',prb[5],2);
wrrev('n7',prb[6],2);
wrrev('n8',prb[7],2);
wrrev('n9',prb[8],2);
wrrev('n10',prb[9],2);
wrrev('n11',prb[10],2);
wrrev('n12',prb[11],2);
wrrev('n13',pbill,2);
wrpct('c1',chb[0],1);
wrpct('c2',chb[1],1);
wrpct('c3',chb[2],1);
wrpct('c4',chb[3],1);
wrpct('c5',chb[4],1);
wrpct('c6',chb[5],1);
wrpct('c7',chb[6],1);
wrpct('c8',chb[7],1);
wrpct('c9',chb[8],1);
wrpct('c10',chb[9],1);
wrpct('c11',chb[10],1);
wrpct('c12',chb[11],1);
wrpct('c13',chgbill,1);
wrrev('zold',cbill,2);
wrrev('znew',pbill,2);
xtemp = pbill - cbill;
wrrev('zchg',xtemp,2);
xtemp = (pbill - cbill)/12.0;
wrrev('zchgm',xtemp,2);

}
pasayten
Ray Peterson
User avatar
tristanbgilb
Posts: 1048
Joined: Tue Sep 01, 2020 9:20 pm
Contact:

Re: www.MethowValley.org

Post by tristanbgilb »

Image
Attachments
Avenger.Cover.jpg
Image

Image <=NUCLEAR BUTTONImage

Image

KFAC-LP 105.5 FM Twisp WA
User avatar
tristanbgilb
Posts: 1048
Joined: Tue Sep 01, 2020 9:20 pm
Contact:

Re: www.MethowValley.org

Post by tristanbgilb »

Image
Attachments
zxcompilerlisting.png
Image

Image <=NUCLEAR BUTTONImage

Image

KFAC-LP 105.5 FM Twisp WA
User avatar
tristanbgilb
Posts: 1048
Joined: Tue Sep 01, 2020 9:20 pm
Contact:

Re: www.MethowValley.org

Post by tristanbgilb »

tristanbgilb wrote: Sun Jan 22, 2023 9:51 am Avenger is my favorite video game for the Timex Sinclair 1000 ZX81


Image
tristanbgilb wrote: Tue Feb 08, 2022 4:01 pm http://www.zx81stuff.org.uk/zx81/jtyone.html

Image
I have the instructions to the ZX-Compiler for the Timex Sinclair 1000 ZX81
SILVERSOFT ZX Compiler

Instruction Manual for Silversoft ZX Compiler

Page 1
SILVERSOFT
Introducing the ZX Compiler
Instructions on loading.
Place the cassette on side A, into the recorder. Follow loading instructions, as found in chapter 16 of the ZX81 manual. If at first the program does not load, try different tone and volume levels. If after this it still does not load, try a different tape recorder. There are two copies of ZX COMPILER on the tape. (Use File name "COMPILER")

About the ZX Compiler
The ZX COMPILER is a program, written in basic and machine code that will change a program in "BASIC" into machine code. This can be used to create programs or sub routines that can run up to twenty or thirty times faster than normal 'BASIC'. Because the ZX81 only has a capacity of 16K ram the compiler works in an integer-only, sub-set of BASIC. To save even more space commands have been left out that are not needed, for example REM:- which is not needed in compiled programs anyway and INPUT:- which can be made by a routine using gets and if....then statements. Once your program to be compiled is written, you run the compiler. After a period of fast mode, the program "NEWS" itself and leaves you with a single rem statement containing the machine code (it looks like random junk).
Once written you may either call the code from within a program or directly from the keyboard using LET X=USR 16595.

INSTRUCTIONS ON USE
The program to be compiled is written in 'REM' statements before line 1000 beyond line 1000 is the compiler. The reason for REM's is so you can have extra commands that can't be keyed-in, in normal BASIC. This does mean though that you will have to key in whole commands for example PRINT is P-R-I-N-T. eg:
1 REM PRINT"HELLO"
In the program there are to be no spaces, except in print statements. Also goto statements must be followed by a 'true' line, for example the following will not work.
1 REM PRINT"HELLO"
2 REM GOTO28
When you type run and newline, the screen will blank for a few seconds and then print up:
ERROR IN LINE 28
Which means it can't find any line 28
The compiler program may only have variables A-Z, no strings or arrays. (These maybe be implemented using other commands such as peek and poke).
-Variables in the compiler are not the same ZX81 Variables.

Page 2
Numbers may be 0-65535. To get a negative number use 65535-x
eg: -2=65536-2
There may seem a lot you can't do but it is enough to write most programs, (such as space invaders, breakout, etc.) The only way to really find out what the compiler can do is use it, read through the examples and work them out.
COMPILER COMMANDS
In this section I will go through all the commands available on the compiler.
In this section (variable) can mean a number of things:
1) A number 0-65535
2) A letter A-Z
3) RND followed by a variable
4)USR Followed by a variable
5) TOP
6) Deek followed by a variable
7) Peek followed by a variable
eg: RNDA RND200 RNDUSRDEEK16514!!
Top and DEEK need explaining, the others should be clear enough. Top will return the first position on the display that can be poked. It's basic equivalent is : PEEK 16396 + 256 *PEEK 16397 + 1
Deek is the opposite of doke and peeks two locations at the same time. (To return a number 0-65535) Top is the equivalent of DEEK 16396+1. The nascom and other computer use these commands. eg: It can be used for poking a Lazer base with one command.
1 REM DOKE TOP 1153
PRINT
This can either be followed by text enclosed in speech marks or a variable, (A-Z) it will print the chrs of the variable. The semi colon at the end of the print is automatic. To print at the start of a new line use the following:
1 REM PRINT 118
(Which is the same as the BASIC PRINT CHRS 118) So print can be used in two forms which are:
1. PRINT "--TEXT--"
2. PRINT (VARIABLE)
GET
This is the same as the BASIC INKEY, except only it returns the code (0-128) of the key pressed. It may only be used in one form, if no key is pressed it returns 128.
1. GET (VARIABLE)
eg: 1 REM GET A 2 REM PRINT A 3 REM GOTO 1
END
It is important that you end a compiler program with either an END if you want execution to stop, or RETURN (see later) if you want to continue the calling BASIC program.
Page 3
PAUSE
This may only be used in one form:
1) PAUSE (VARIABLE)
It is a delay, the length of which is determined by the (VARIABLE). The longest delay possible would be 65535, it lasts for 2 seconds!!
CLS
This is the same as BASIC CLS except it clears all 24 lines of the display, not just 22. It has only one form:
1. CLS
MOVE
This is the same as the BASIC PRINT AT, except you may "PRINT AT" all 24 lines down. It takes only one form:
1. MOVE (VARIABLE),(VARIABLE)
eg: 1 REM MOVE 23, 10 2 REM PRINT "HELLO" 3 REM END
LET
This is like the BASIC LET statement except you may not have long equations or brackets. It may take only two forms:
1. LET (VARIABLE) = (VARIABLE)
2. LET (VARIABLE) = (OPERATOR) (VARIABLE)
(OPERATOR) can be either +,-,* or /
SCROLL
This is the same as the BASIC SCROLL except that it is a lot quicker and scrolls all 24 lines of the screen.
GOTO
This is like the BASIC goto except the line number must exist. It may only take one form:
1. GOTO NUMBER (1-999)
GOSUB
This is the same as BASIC GOSUB, except for destination line number which must exist. It can only take one form:
1. GOSUB NUMBER (1-999)
RETURN
Used in conjunction with GOSUB, this is identical t its BASIC equivalent. Used when not in a GOSUB sub-routine, it will return you to BASIC and continue with the calling program. It may only take one form:
1. RETURN
PLOT
This is the same as BASIC PLOT. It may take only one form:
1. PLOT (VARIABLE), (VARIABLE)
UNPLOT
This is the same as BASIC UNPLOT. It may take only one form:
1. UNPLOT (VARIABLE),(VARIABLE)
POKE
This is the same as its BASIC equivalent. It may only take one form:
1. POKE (VARIABLE),(VARIABLE)


Page 4
DOKE
Is used on the nascom and other computer, it pokes two locations at the same time with a number of up to 65535. The low byte of the number at the address and the high byte at address +1. For more information see example programs. It can only take one form:
1. DOKE (VARIABLE),(VARIABLE)
IF is used in only one way:
1. IF (VARIABLE) (SIGN)(VARIABLE)______
(SIGN) can mean either =,<>,<>. There is no need to use the then statement. For more information see example programs.
eg: IF A>2 GOTO 10
SCROLL
These are all the commands allowed in the compiler. But as you can see from the example programs, these are enough.
EXAMPLE 1
This program will invert the screen, then Return to basic not stop. It will invert all 24 lines of the display.
1 REM LETB=24
2 REM LETA=TOP
3 REM IFPEEKA=118GOTO10
4 REM LETZ=PEEKA+128 : NUMBER OF LINES
5 REM POKEA,Z : TOP OF SCREEN
6 REM LETA=A+1 : END OF LINE ?
7 REM GOTO3 : INVERT IT
10 REM LET B=B-1
11 REM IFB=0RETURN : "RETURN" TO BASIC, USE END
12 REM GOTO6 STOP WITH AN ERROR CODE:
Try this program out, then try it in BASIC to see how slow it is.
EXAMPLE 2
This program demonstrates the DEEK and DOKE commands, DOKE is used to 'save' the variable while it is used for something else, DEEK reads it back again.
1 REM LETA=45192
2 REM DOKE30000,A
3 REM LETA=0
4 REM LETA=DEEK30000
5 REM IFA<>45192PRINT"THIS WILL NEVER BE PRINTED"
6 REM END
In this program location 30000 was chosen because it is high up in the memory and will not interfere with anything.
WHEN YOU HAVE WRITTEN A PROGRAM
When you have written your program in REM statements, SAVE a copy on cassette (in case you have to de-bug it) Then RUN, this will run the compiler as it will go past REMS. After a delay (10mins for 4k program0 the screen will return. If it says error, correct error and re-run it. If it comes up with one rem followed by junk then it has finished compiling, BEFORE YOU DO ANYTHING ELSE type in: 2 RAND USR 16595

Page 5
Then SAVE another copy of the program and run it. If the program does something odd, try and see what is happening, re-load the first copy and correct the program.
MORE FACTS
Don't forget in machine code there is no 'break' key to test for one use.
1. REM GETA
2. REM IFA=0END
Even a one line compiler program when compiled may seem to take up a lot of room, this is quite normal because about 1K is taken up with variables and routines. The compiler was really developed for small fast routines to be used in a BASIC program or entire games in machine code.
If you want to interchange basic variables and compiler variables, the compiler variables are held at 16514 low byte first, high byte next. A(low) is at 16514, B(low) is at 16515 and so on.
In the program you will see two sets of inverse AJGs this is so the author can identify any compiled program. (No program may be used personal gain which in any way connected with the compiler without the permission of the author.
Try to use POKE and PEEK, (deeks and dokes) more as they are very fast in the compiler. Things like PRINT, PRINT AT, PLOT, UNPLOT use basic routines to space so they will only be executed at about twice the speed as normal.
The RND function is not very random when displaying the results, but it is good enough for normal random decisions. (This is again due to the lack of space available). Compilers available for other computers may need 4K of code for one line of compiled program!!
MORE EXAMPLES
1) Add all the numbers 1-1000 together.
(returns the answer in s 165114+16515)
1 REM LETA=0
2 REM LETC=0
3 REM LETA=A+C
4 REM LETC=C+1
5 REM IFC 101 GOTO3
6 REM END
Type this in, then RUN it, to see the answer
PRINT PEEK 16514+256*PEEK 16515
try out he program in BASIC as well and see the difference in speed

Page 6
2)
1 REM LET P=0
2 REM MOVE23,P
3 REM PRINT34
4 REM GET A
5 REM IFA=33LETp=p-1 key 5
6 REM IFA=36LETp=P+1 key 8
7 REM IFP=65535LETP=0
8 REM IFP=31LETp=30
9 REM SCROLL
10 REM GOTO2


Image
Attachments
Timex-Sinclair1000UserManual_0000.jpg
Image

Image <=NUCLEAR BUTTONImage

Image

KFAC-LP 105.5 FM Twisp WA
User avatar
tristanbgilb
Posts: 1048
Joined: Tue Sep 01, 2020 9:20 pm
Contact:

Re: www.MethowValley.org

Post by tristanbgilb »

Image
Attachments
Tristan B Gilbert.gif
Tristan B Gilbert.gif (842.44 KiB) Viewed 16634 times
Image

Image <=NUCLEAR BUTTONImage

Image

KFAC-LP 105.5 FM Twisp WA
User avatar
tristanbgilb
Posts: 1048
Joined: Tue Sep 01, 2020 9:20 pm
Contact:

Re: www.MethowValley.org

Post by tristanbgilb »

Avenger is my favorite video game for the Timex Sinclair 1000 ZX81

Image
Attachments
avenger.png
Image

Image <=NUCLEAR BUTTONImage

Image

KFAC-LP 105.5 FM Twisp WA
User avatar
tristanbgilb
Posts: 1048
Joined: Tue Sep 01, 2020 9:20 pm
Contact:

Re: www.MethowValley.org

Post by tristanbgilb »

Image

WATCH La Grange

Terry once told me that he was always aware of the positioning of my camera. On this day at the Open Merc, Terry allowed me to video one of his best licks from La Grange up close to share with other guitar masters one day.
Attachments
Terry Lee Hardesty LAGRANGE open merc 2011 04 13 06H31M PM_gif.gif
Terry Lee Hardesty LAGRANGE open merc 2011 04 13 06H31M PM_gif.gif (3.52 MiB) Viewed 16653 times
Terry Lee Hardesty LAGRANGE open merc.gif
Terry Lee Hardesty LAGRANGE open merc.gif (19.58 MiB) Viewed 16653 times
Image

Image <=NUCLEAR BUTTONImage

Image

KFAC-LP 105.5 FM Twisp WA
User avatar
tristanbgilb
Posts: 1048
Joined: Tue Sep 01, 2020 9:20 pm
Contact:

Re: www.MethowValley.org

Post by tristanbgilb »

PAL wrote: Sat Jan 21, 2023 8:17 am Thanks Tristan. We lost a goodun'. Loved his music and energy and Linda's too.
I am working with Linda to preserve Terry's recordings and release them digitally through a website called www.Soundrop.com .

https://youtu.be/z16ROkoaCko

Image

This La Grange audio is my first video camera audio of Terry Lee Hardesty that I have gotten licensed and monetized with digital distribution. I have hundreds of hours of Terry and his band on video and www.DryLander.com is helping me restore the audio from these old recordings.
Last edited by tristanbgilb on Sun Jan 22, 2023 8:33 am, edited 1 time in total.
Image

Image <=NUCLEAR BUTTONImage

Image

KFAC-LP 105.5 FM Twisp WA
User avatar
tristanbgilb
Posts: 1048
Joined: Tue Sep 01, 2020 9:20 pm
Contact:

Re: www.MethowValley.org

Post by tristanbgilb »

This is a single off Dennis Morgan's CD "Favorites of Mine".

Image

Links to song on Youtube

Dennis is a great person, Terry's loyal scout and Bass Guitar and Mr. Smooth on the vocal.
Attachments
10dennis_dont_touch_my_heart_again.png
Image

Image <=NUCLEAR BUTTONImage

Image

KFAC-LP 105.5 FM Twisp WA
User avatar
tristanbgilb
Posts: 1048
Joined: Tue Sep 01, 2020 9:20 pm
Contact:

Re: www.MethowValley.org

Post by tristanbgilb »

Image

This is a picture of my friend Terry Lee Hardesty playing guitar with Merle Haggard.
Attachments
Merle Haggard and Terry Lee Hardesty at Merle's Ranch.gif
Merle Haggard and Terry Lee Hardesty at Merle's Ranch.gif (7.5 MiB) Viewed 16741 times
Merle Haggard and Terry Lee Hardesty at Merle's Ranch AUG 21 2010 08 31AM_gif.gif
Image

Image <=NUCLEAR BUTTONImage

Image

KFAC-LP 105.5 FM Twisp WA
PAL
Posts: 1304
Joined: Tue May 25, 2021 1:25 pm
Contact:

Re: www.MethowValley.org

Post by PAL »

Thanks Tristan. We lost a goodun'. Loved his music and energy and Linda's too.
Pearl Cherrington
User avatar
tristanbgilb
Posts: 1048
Joined: Tue Sep 01, 2020 9:20 pm
Contact:

Re: www.MethowValley.org

Post by tristanbgilb »

Image

Terry Lee Hardesty and Merle Haggard - Linda Hardesty - Dennis Morgan - Camera: Tristan B Gilbert
Attachments
Merle Haggard entering backstage for concert as Terry Lee Hardesty and Dennis Morgan run security_gif.gif
Merle Haggard entering backstage for concert as Terry Lee Hardesty and Dennis Morgan run security_gif.gif (11.16 MiB) Viewed 16738 times
Image

Image <=NUCLEAR BUTTONImage

Image

KFAC-LP 105.5 FM Twisp WA
User avatar
tristanbgilb
Posts: 1048
Joined: Tue Sep 01, 2020 9:20 pm
Contact:

Re: www.MethowValley.org

Post by tristanbgilb »

Click the Terry Lee Hardesty & The Eagle River Band Album Cover to hear Terry's "Lover's Moon" Album on Youtube.

Image
Attachments
Terry Lee Hardesty Lover's Moon Album Cover.jpg
Image

Image <=NUCLEAR BUTTONImage

Image

KFAC-LP 105.5 FM Twisp WA
User avatar
tristanbgilb
Posts: 1048
Joined: Tue Sep 01, 2020 9:20 pm
Contact:

Re: www.MethowValley.org

Post by tristanbgilb »

Click Album Cover to Hear Terry Lee Hardesty

Image

I'm Tired of Being Something (That Means Nothing to You)
Attachments
terry_hardesty_tired_artwork_2022.jpg
Last edited by tristanbgilb on Sun Jan 22, 2023 8:25 am, edited 1 time in total.
Image

Image <=NUCLEAR BUTTONImage

Image

KFAC-LP 105.5 FM Twisp WA
User avatar
tristanbgilb
Posts: 1048
Joined: Tue Sep 01, 2020 9:20 pm
Contact:

Re: www.MethowValley.org

Post by tristanbgilb »

La Grange audio

Image

This link takes you to youtube to hear Terry Lee Hardesty and The Eagle River Band playing La Grange at the Open Merc in Twisp Washington.
Attachments
terry_hardesty_lagrange1.png
Last edited by tristanbgilb on Sun Jan 22, 2023 8:36 am, edited 2 times in total.
Image

Image <=NUCLEAR BUTTONImage

Image

KFAC-LP 105.5 FM Twisp WA
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests