JavaLikeCalc.JavaScript
//Get programms into library list
if(f_start) {
	prEndRun = true;
	lib_value = "";
	btStop_active = false;
	prCnt = 0;
}
if(prExtMode.isEVal() || prExtProg.isEVal() || prExtStartTm.isEVal() || prExtCurCom.isEVal() || prExtWork.isEVal())
	return;

//Check for program list update
if(f_start || (prCnt%max(1,f_frq)) == 0) {
	rez = SYS.BD.nodeAt(dbDB,".").SQLReq("SELECT name FROM "+dbProgs+";");
	curPrLst = "";
	for(i_p = 1; i_p < rez.length; i_p++)
		curPrLst += (curPrLst.length?"\n":"")+rez[i_p][0];
	curPrLst = curPrLst.split("\n").sort().join("\n");
	if(curPrLst != lib_items) lib_items = curPrLst;
}

//Check for ready
btStart_active = prExtProg.length;

if(prExtMode <= 0)		{ btStart_img = "start"; btStart_value = false; btStop_active = btPass_active = false; }
else if(prExtMode == 1){ btStart_img = "pause"; btStart_value = false; btStop_active = btPass_active = true; prEndRun = false; }
else if(prExtMode == 2){ btStart_img = "start"; btStart_value = true; btStop_active = true; btPass_active = true; }

//Prepare call status document
pTxt = "";
if((prExtMode == 1 || prExtMode == 2 || prExtMode == 3 || ((prCnt%max(1,f_frq)) == 0 && prExtMode <= 0))) {
	pTxt = "<body>";
	off = 0;
	labProg_arg0val = prExtWork.attr("name");

	if(prExtMode < 0 && !prEndRun) {
		prEndRun = true;
		prog_aCur = -1;	//Archiving
	}

	//Build result table
	pTxt += "<i>"+tr("Program:")+" </i>"+Special.FLibSYS.strEnc2HTML(labProg_arg0val)+"<br/>\n";
	if(prExtMode > 0 || (prExtMode < 0 && prog_aCur < 0)) {
		pTxt += "<i>"+tr("Started:")+" </i>"+SYS.strftime(prExtStartTm)+"<br/>\n";
		if(prog_aCur < 0) {
			if(prExtMode == -1) pTxt += "<i>"+tr("Status:")+" </i>"+tr("Error")+"<br/>\n";
			else if(prExtMode == -2) pTxt += "<i>"+tr("Status:")+" </i>"+tr("Successful finish")+"<br/>\n";
			else if(prExtMode == -3) pTxt += "<i>"+tr("Status:")+" </i>"+tr("Terminated")+"<br/>\n";
			else pTxt += "<i>"+tr("Status:")+" </i>"+tr("Unknown")+"<br/>\n";
		}
	}
	if(prExtMode == 1) {
		wtm = max(0,prExtWork.attr("wtm").toInt()-(SYS.time()-prExtStartTm));
		pTxt += "<i>"+tr("Remain:")+" </i>"+(wtm/3600).toString(10)+":"+((wtm/60)%60).toString(10,2)+":"+(wtm%60).toString(10,2)+"<br/>";
	}
	pTxt += "<table border='1' cellpadding='2' cellspacing='0' width='100%'>\n"
					"<tr><th>"+tr("#")+"</th><th>"+tr("Command")+"</th><th>"+tr("Comments")+"</th><th>"+tr("Time")+"</th>";
	pTxt += "</tr>\n";

	for(comElN = prExtWork, comPos = 0, comLev = 0, comCur = true, comAftCur = false, comN = "", comPath = ""; true; comPos++) {
		if(comPos >= comElN.childSize()) {
			if((comElN=comElN.parent())) {
				comLev--;
				comPos = comElN.attr("seekPos").toInt();
				comCur = comElN.attr("comCur").toInt();
				comN = comElN.attr("comN");
				comPath = comElN.attr("comPath");
				continue;
			}
			break;
		}
		comEl = comElN.childGet(comPos);
		comN_ = (comN.length?comN+":":"") + comPos;
		comPath_ = (comPath.length?comPath+": ":"") + (comEl.attr("name").length?comEl.attr("name"):comEl.attr("id"));
		isCurCmd = comCur && (tmpComLv=prExtCurCom.parse(comLev,":")).length && tmpComLv.toInt() == comPos && !prExtCurCom.parse(comLev+1,":").length;
		if(isCurCmd) comAftCur = true;
		rezVl = comEl.attr("rez");
		toMark = true;
		if((isCurCmd || (rezVl.length && rezVl.toInt() == 0)) && (prExtMode > 0 || (prExtMode < 0 && prog_aCur < 0)))				pTxt += "<tr class='"+(prEndRun?"err":"run")+"'>";
		else if(!comAftCur && (prExtMode > 0 || (prExtMode < 0 && prog_aCur < 0)))	pTxt += "<tr class='"+((rezVl.toInt()==-10)?"skip":((rezVl.toInt()<0)?"err":"pass"))+"'>";
		else { pTxt += "<tr>"; toMark = false; }
		pTxt += "<td>"+comN_+"</td>";
		pTxt += "<td>"+Special.FLibSYS.strEnc2HTML(comPath_)+(comEl.attr("backgrnd")?" "+tr("(background)"):"")+"</td><td>";
		if(toMark && rezVl.parse(1,":").length) pTxt += Special.FLibSYS.strEnc2HTML(rezVl.parse(1,":"));
		else {
			//Arguments values
			for(i_a = 1; i_a <= 5; i_a++)
				if(comEl.attr("labArg"+i_a).length)
					pTxt += Special.FLibSYS.strEnc2HTML(comEl.attr("labArg"+i_a).parse(0,"|")+" = "+comEl.attr("arg"+i_a)+"; ");
		}
		pTxt += "</td>";
		comTm = comEl.attr("tm").toInt();
		if(toMark && comTm) {
			comTm -= prExtStartTm;
			pTxt += "<td>"+(comTm/3600).toString(10)+":"+
									((comTm/60)%60).toString(10,2)+":"+
									(comTm%60).toString(10,2)+"</td>";
		}
		else pTxt += "<td>---</td>";
		pTxt += "</tr>\n";

		if(comEl.childSize()) {
			comElN.setAttr("seekPos",comPos).setAttr("comCur",comCur).setAttr("comN",comN).setAttr("comPath",comPath);
			comElN = comEl;
			comCur = comCur && (tmpComLv=prExtCurCom.parse(comLev,":")).length && tmpComLv.toInt() == comPos;
			comPos = -1; comLev++; comN = comN_; comPath = comPath_;
		}
	}
	pTxt += "</table></body>";
}

if(!prExtProg.length && f_start) pTxt = "<body><H1>"+tr("Select a program please")+"</H1></body>";

if(pTxt.length) {
	this.prog.attrSet("aDoc",pTxt);
	if(this.prog.attr("aCur") == this.prog.attr("vCur")) prog_doc = pTxt;
}

prCnt++;

//Events for commands process
for(ev_rez = "", off = 0; (evCur=event.parse(0,"\n",off)).length; ) {
	//SYS.messDebug("Prescription edit control","Event: "+evCur);
	if(evCur == "ws_TreeChange:/lib") {
		prog_vCur = prog_aCur;
		prExtProg = lib_value;
	}
	else if(evCur == "ws_BtPress:/btStart") {
		if(prExtMode <= 0)	prExtMode = 1;
		else if(prExtMode == 1)	prExtMode = 2;
		prog_vCur = prog_aCur;
	}
	else if(evCur == "ws_BtRelease:/btStart")	prExtMode = 1;
	else if(evCur == "ws_BtPress:/btStop" && prExtMode >= 0) {
		prExtMode = prExtCurCom = 0;
		prog_vCur = prog_aCur;
	}
	else if(evCur == "ws_BtPress:/btPass" && (prExtMode == 1 || prExtMode == 2))	prExtMode = 3;
	else ev_rez += (evCur+"\n");
}
event = ev_rez;

//Programm select process
if(!prExtProg.length || lib_items.search("^"+prExtProg.replace(new RegExp("(\\[|\\]|\\(|\\)|\\.|\\+|\\*|\\?|\\^|\\$|\\<|\\>|\\{|\\}|\\\\)","g"),"\\$1")+"$","m") < 0)
	prExtProg = lib_value;
else lib_value = prExtProg;