bonjour,

j'ai essayé de créer un objet (c'est mon premier) mais ça ne marche pas

utilisation de l'objet :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
	var myObj = new DataSerial();
	myObj.Add(1);
	myObj.Add(0);
	myObj.Add(1);
	myObj.Add(0);
	alert(myObj.Sort);

code de l'objet :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
 
/******************/			
function DataSerial()
{
	this.prototype.BitNumb = 3;
	this.prototype.Char = 0;
	this.prototype.Lenght = 0;
	this.prototype.String = '';
	this.prototype.Add = Add;
	this.prototype.Sort = Sort;
	this.prototype.Erase = Erase;
}
 
function Erase() // initialisation de l'objet
{
	this.prototype.BitNumb = 3;
	this.prototype.Char = 0;
	this.prototype.Lenght = 0;
	this.prototype.String = '';
}
 
function Add(myCheckBox) // ajout d'un bit
{
	if (this.BitNumb == 3)
		this.Lenght++;
 
	this.Char |= (myCheckBox * 1) << this.BitNumb--
 
	if (this.BitNumb < 0)
	{
		this.BitNumb = 3;
		this.String += this.Char.toString(16);
		this.Char = '';
	}
}
 
function Sort() // recuperation de la chaine de caractere 
{
	if (this.Lenght != 3)
	{
		this.String += this.Char.toString(16);
	}
	return this.String;
}
 
/******************/
=> que dois-je faire ?