www.MethowValley.org

User avatar
tristanbgilb
Posts: 916
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.
www.TristanGilbert.com

Image <=NUCLEAR BUTTONImage

Image

RADIO
User avatar
pasayten
Posts: 1627
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: 916
Joined: Tue Sep 01, 2020 9:20 pm
Contact:

Re: www.MethowValley.org

Post by tristanbgilb »

Image
Attachments
Avenger.Cover.jpg
www.TristanGilbert.com

Image <=NUCLEAR BUTTONImage

Image

RADIO
User avatar
tristanbgilb
Posts: 916
Joined: Tue Sep 01, 2020 9:20 pm
Contact:

Re: www.MethowValley.org

Post by tristanbgilb »

Image
Attachments
zxcompilerlisting.png
www.TristanGilbert.com

Image <=NUCLEAR BUTTONImage

Image

RADIO
User avatar
tristanbgilb
Posts: 916
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
www.TristanGilbert.com

Image <=NUCLEAR BUTTONImage

Image

RADIO
User avatar
tristanbgilb
Posts: 916
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 283 times
www.TristanGilbert.com

Image <=NUCLEAR BUTTONImage

Image

RADIO
User avatar
tristanbgilb
Posts: 916
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
www.TristanGilbert.com

Image <=NUCLEAR BUTTONImage

Image

RADIO
User avatar
tristanbgilb
Posts: 916
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 305 times
Terry Lee Hardesty LAGRANGE open merc.gif
Terry Lee Hardesty LAGRANGE open merc.gif (19.58 MiB) Viewed 305 times
www.TristanGilbert.com

Image <=NUCLEAR BUTTONImage

Image

RADIO
User avatar
tristanbgilb
Posts: 916
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.
www.TristanGilbert.com

Image <=NUCLEAR BUTTONImage

Image

RADIO
User avatar
tristanbgilb
Posts: 916
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
www.TristanGilbert.com

Image <=NUCLEAR BUTTONImage

Image

RADIO
User avatar
tristanbgilb
Posts: 916
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 360 times
Merle Haggard and Terry Lee Hardesty at Merle's Ranch AUG 21 2010 08 31AM_gif.gif
www.TristanGilbert.com

Image <=NUCLEAR BUTTONImage

Image

RADIO
PAL
Posts: 756
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: 916
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 358 times
www.TristanGilbert.com

Image <=NUCLEAR BUTTONImage

Image

RADIO
User avatar
tristanbgilb
Posts: 916
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
www.TristanGilbert.com

Image <=NUCLEAR BUTTONImage

Image

RADIO
User avatar
tristanbgilb
Posts: 916
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.
www.TristanGilbert.com

Image <=NUCLEAR BUTTONImage

Image

RADIO
User avatar
tristanbgilb
Posts: 916
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.
www.TristanGilbert.com

Image <=NUCLEAR BUTTONImage

Image

RADIO
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests