quoteGetter.js
Esta función se encarga de extraer el parámetro especificado desde la línea actual de la TOC, desde 1 hasta 4.
Esta función NO lleva a cabo comprobaciones si se pide un parámetro menor a 1 o mayor a 5, ya que la lógica principal de CHMEmulator jamás efectu&uacte;a tales operaciones, sino que se guía por el número de parámetros que encuentra para la entrada actual y, así, nunca busca en una posición equivocada.
function quoteGetter(NLine, quoteNumber)
{
dqSwitcher = 0; ;//1. Flag to switch from start of parameter
;// (first/odd doublequote found) to end of
;// parameter (second/even doublequote found).
it1 = 0; ;//2. Iterator
tmp = allTrim(CHM_toc[NLine]); ;//3. Temporary TOC line copy
lng1 = tmp.length-1; ;//4. Line length
qnx = quoteNumber; ;//5. Detected through the 0.5
;// doublequote pair method
dqCounter = 0; ;//6. Doublequote counter
toRet = ""; ;//7. Resultant substring, gathered
;// character by character
for(it1=0; it1<=lng1; it1++)
{
;//It means that in fact we have finished founding
;//and gathering the parameter number (practically
;//in parallel, or very tightly):
if(dqCounter>=qnx)
{
break;
}
if(tmp.charAt(it1)=='\"') ;//If char IS doublequote
{
if(dqSwitcher) ;//Ending doublequote
{
dqSwitcher=0; ;//Switch to start
dqCounter+=0.5; ;//Add one quote, or 0.5 parameter
}
else ;//Starting doublequote
{
dqSwitcher=1; ;//Switch to end
dqCounter+=0.5; ;//Add one quote, or 0.5 parameter
}
continue;
}
else
{
;//If char is NOT doublequote, we will
;//limit ourselves to gather one character
;//from the parameter:
;//It means that we are at the start of
;//the specified parameter, and, while we don't
;//find any other doublequote for ending, we will
;//keep getting content from this parameter.
if(dqCounter==qnx-0.5)
{
toRet += tmp.charAt(it1);
}
}
}
return(toRet);
}