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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
function createModule()
{
...
...
this.iCountModule = 0;
this.iCurrentIndex = 0;
this.arrayIndex = new Array(MAX_COUNT);
this.arrayName = new Array(MAX_COUNT);
this.newWindow = new Array(MAX_COUNT);
this.lastError = "";
this.getIndex = function getIndex(szName)
{
var bfWork = true;
var iIndex = -1;
if (szName == "") { this.lastError = "Need a name !"; return -1; }
for (var i=0; i<MAX_COUNT & bfWork; i++)
{
if ((this.arrayIndex[i] == 1) && (this.arrayName[i].indexOf(szName) == 0 ) )
{
iIndex = i;
bfWork = false;
}
}
if (bfWork) this.lastError = "("+szName+") Object not found !";
return iIndex;
}
this.getName = function getName(iIndex)
{
var bfFound = false;
var sName = new String();
if (this.arrayIndex[iIndex] == 1)
{
sName = this.arrayName[iIndex];
bfFound = true;
}
if (!bfFound) { this.lastError = "Can't find name, index "+iIndex+" : empty !"; return -1; }
return sName;
}
this.addWindow = function addWindow(szName, iPosX, iPosY, iWidth, iHeight)
{
var bfWork = true;
var iIndex = -1;
if (this.iCountModule >= MAX_COUNT) { this.lastError = "Not free space !"; return -1; }
if (szName == "") { this.lastError = "Need a name !"; return -1; }
function newWindow(szName, iPosX, iPosY, iWidth, iHeight)
{
this.iCountModule++;
// Cette manip ne fait que re-creer une instance mais moi j'ai besoin
// de l'object en cours...
//
this.constructor = createModule;
this.inst = new this.constructor();
this.constructor();
// ---------- ICI ?
alert(this.getName(0)); // Resultat: erreur retournee du type n'existe pas (-1) alors que si... bref c'est lourd
// ---------- ICI ?
delete(this.inst);
...
...
return this;
}
|
Partager