// -- AUTHOR: Filippo Spadaro
// -- PROGRAMMER: Filippo Spadaro
// -- LASTREVIEW: 12 ottobre 2002
// -- SITE URL: http://utenti.lycos.it/nienteperniente

// -- rmbr: sostituire **test.js nelle importazioni JScript dei file HTML
// ##9
path = "06test.html";
// ##9
path_fine = "06test_fine.html";


// -- definizioni array --
var t = new Array();

var txtA = new Array();
var txtB = new Array();
var txtC = new Array();
var txtD = new Array();

var r = new Array();
var esatta = new Array();
commento = new Array();



// -- NB: l'utente deve riempire solo i campi:
// -- txt*[*], t[*], r[*], p*[*]
// -- * --
txtA[0]="char, int, float";
txtB[0]="char, float, int";
txtC[0]="char, int, real";
txtD[0]="char, double, float";
t[0]="Gli specificatori <FONT color=blue><CODE>%c, %d, %f</CODE></FONT> specificano rispettivamente i tipi:<BR>";
esatta[0] = "A";
commento[0] = "";


// -- * --
txtA[1]="1.5";
txtB[1]="1";
txtC[1]="emette un syntax error in fase di compilazione";
txtD[1]="1, ma emette un warning in fase di complazione";
t[1]="Il seguente listato: <FONT color=blue><CODE><BR>#include &lt;stdio.h&gt;<BR>main ()<BR>{<BR>&nbsp;int numero = 3/2;<BR>&nbsp;printf(\x22La variabile numero ha il valore di %d\x22, numero);<BR>&nbsp;return 0;<BR>}<BR></CODE></FONT>cosa visualizza?<BR>";
esatta[1] = "B";
commento[1] = "";

// -- * --
txtA[2]="una funzione di acquisizione di dati immessi da tastiera e fa parte della libreria <FONT color=blue><CODE>iostream.h</CODE></FONT>";
txtB[2]="una funzione di acquisizione di dati immessi da tastiera e fa parte della libreria <FONT color=blue><CODE>stdio.h</CODE></FONT>";
txtC[2]="una funzione che converte i dati immessi da tastiera dal tipo char al tipo int e fa parte della libreria <FONT color=blue><CODE>stdio.h</CODE></FONT>";
txtD[2]="una funzione che converte i dati immessi da tastiera dal tipo char al tipo int e fa parte della libreria <FONT color=blue><CODE>iostream.h</CODE></FONT>";
t[2]= "La funzione <FONT color=blue><CODE>int scanf(const char *formato [, indirizzi, ...]);</CODE></FONT> è:<BR>";
esatta[2] = "B";
commento[2] = "";

// -- * --
txtA[3]="&nbsp;&nbsp;!=";
txtB[3]="&nbsp;&nbsp;==";
txtC[3]="&nbsp;&nbsp;=";
txtD[3]="&nbsp;&nbsp;:=";
t[3]= "L'operazione di assegnazione di un valore ad una variabile è attuata utilizzando l'operatore:<BR>";
esatta[3] = "C";
commento[3] = "";

// -- * --
txtA[4]="&nbsp;&nbsp;%%";
txtB[4]="&nbsp;&nbsp;%";
txtC[4]="&nbsp;&nbsp;/";
txtD[4]="&nbsp;&nbsp;MOD";
t[4]= "Il resto di una divisione si trova con l'operatore:<BR>";
esatta[4] = "B";
commento[4] = "";

// -- * --
txtA[5]="a = 5; b = 6";
txtB[5]="a = 6; b = 6";
txtC[5]="a = 5; b = 5";
txtD[5]="a = 6; b = 5";
t[5]= "Determinare i valori delle variabili <I>a</I> e <I>b</I> dopo le seguenti operazioni di assegnamento e di incremento:<FONT color=blue><CODE><BR>int a = 5;<BR>int b = a++;</CODE></FONT><BR>";
esatta[5] = "D";
commento[5] = "";

// -- * --
txtA[6]="XOR operatore di manipolazione di bit e XOR operatore logico";
txtB[6]="AND operatore di manipolazione di bit e AND operatore logico";
txtC[6]="NOT operatore di manipolazione di bit e NOT operatore logico";
txtD[6]="OR operatore di manipolazione di bit e OR operatore logico";
t[6]= "Il significato degli operatori <FONT color=blue><CODE>|</CODE></FONT> e <FONT color=blue><CODE>||</CODE></FONT> è:<BR>";
esatta[6] = "D";
commento[6] = "";

// -- * --
txtA[7]="XOR operatore di manipolazione di bit";
txtB[7]="NOT operatore di manipolazione di bit";
txtC[7]="OR operatore di manipolazione di bit";
txtD[7]="AND operatore di manipolazione di bit";
t[7]= "Il significato dell'operatore <FONT color=blue><CODE>^</CODE></FONT> è:<BR>";
esatta[7] = "A";
commento[7] = "";

// -- * --
txtA[8]="(10011100)<SUB>2</SUB>";
txtB[8]="(00110100)<SUB>2</SUB>";
txtC[8]="(00011100)<SUB>2</SUB>";
txtD[8]="(01011100)<SUB>2</SUB>";
t[8]= "Risolvere il calcolo <FONT color=blue><CODE>(00111101)<SUB>2</SUB> & (00011110)<SUB>2</SUB></CODE></FONT> :<BR>";
esatta[8] = "C";
commento[8] = "";

// -- * --
txtA[9]="a = 4; b = 5";
txtB[9]="a = 4; b = 4";
txtC[9]="a = 5; b = 4";
txtD[9]="a = 5; b = 5";
t[9]= "Determinare i valori delle variabili <I>a</I> e <I>b</I> dopo le seguenti operazioni di assegnamento e di decremento:<FONT color=blue><CODE><BR>int a = 5;<BR>int b = --a;</CODE></FONT><BR><BR>";
esatta[9] = "B";
commento[9] = "";


// -- funzioni --
function createTempCookie(name, value) {
  	document.cookie=name + "=" + value + ";";
}


function extractCookieValue(val) {
	if ((endOfCookie = document.cookie.indexOf(";", val)) == -1) {
		endOfCookie = document.cookie.length;
	}
  return unescape(document.cookie.substring(val,endOfCookie));
}


function ReadCookie(cookiename) {
	var numOfCookies = document.cookie.length;
	var nameOfCookie = cookiename + "=";
	var cookieLen = nameOfCookie.length;
	var x = 0;
	while (x <= numOfCookies) {
		var y = (x + cookieLen);
		if (document.cookie.substring(x, y) == nameOfCookie)
			return (extractCookieValue(y));
			x = document.cookie.indexOf(" ", x) + 1;
			if (x == 0)
				break;
  		}
	return (null);
}


function getData(i) {
	separatore = "#"
	var VecchioValore = ReadCookie("ordine");
	var NuovoValore = VecchioValore + separatore + document.forms[0].elements[i].name;
	test = parseInt(NuovoValore.charAt(0));
	if ((test > 0) && (test < 9))
	test = parseInt(NuovoValore.charAt(0)) + 1;
	else if (test == 9)
	test = 0;
	else if (test == 0)
	test = "X";
	createTempCookie("ordine", test + NuovoValore);
	//userCookie = ReadCookie("ordine");
}


function leggiDati() {
	userCookie = ReadCookie("ordine");
	var u = 1;
	var bool = 0;
	var totale = 0;
	var numero = new Array();
     	while (bool == 0) {
		if (userCookie.charAt(u) == "") 
			bool = 1;
		if (userCookie.charAt(u) == "#") {	 
			document.write("&nbsp;");
			u+=1;
		}
		if (userCookie.charAt(u) == "£") {
				u+=1;	
				totale = totale 
				+ parseInt(userCookie.charAt(u))*1000
				+ parseInt(userCookie.charAt(u+1))*100
				+ parseInt(userCookie.charAt(u+2))*10
				+ parseInt(userCookie.charAt(u+3));
		}
		u+=1;
	}
	document.write("<BR><FONT SIZE=4 FACE=\x22 courier new\x22 color=Maroon><B>Punteggio parziale: </B></FONT>" 
			+ "<FONT SIZE=5 FACE=\x22 courier new\x22 color=Navy><B>" 
			+ totale + "</B></FONT>");
}


function NuovoOrdine() {	
	createTempCookie("ordine", "1");
}

