Chimera
05-31-2003, 07:20 AM
Inside a function I have filled local arrays a[0-19] .. z[0-20] (aswell as ones for numbers etc.) with data.
I'd like to call a separate function to add to data in the global line[] array with the array data of the character from inputText but how do I pass each character as an array without having to repeat the lines as I have with numbers?
line = New array(20);
function font1(inputText) {
..array data..
for(i=0; i < inputText.length; i++) {
var currchar = inputText.charAt(i);
if(currchar == "@") line = dolines(at,20)
else if(currchar == ".") line = dolines(fs,20)
else if(currchar == "0") line = dolines(zero,20)
else if(currchar == "1") line = dolines(one,20)
else if(currchar == "2") line = dolines(two,20)
else if(currchar == "3") line = dolines(three,20)
else if(currchar == "4") line = dolines(four,20)
else if(currchar == "5") line = dolines(five,20)
else if(currchar == "6") line = dolines(six,20)
else if(currchar == "7") line = dolines(seven,20)
else if(currchar == "8") line = dolines(eight,20)
else if(currchar == "9") line = dolines(nine,20)
else line = dolines(currchar,20);
}
..code to ouput line[] array..
}
function dolines(currchar,nl)
{
for(i=0; i<=nl; i++) {
line[i] += currchar[i];
}
return line;
}
or if there's an even better way someone can think of doing this..?
I'd like to call a separate function to add to data in the global line[] array with the array data of the character from inputText but how do I pass each character as an array without having to repeat the lines as I have with numbers?
line = New array(20);
function font1(inputText) {
..array data..
for(i=0; i < inputText.length; i++) {
var currchar = inputText.charAt(i);
if(currchar == "@") line = dolines(at,20)
else if(currchar == ".") line = dolines(fs,20)
else if(currchar == "0") line = dolines(zero,20)
else if(currchar == "1") line = dolines(one,20)
else if(currchar == "2") line = dolines(two,20)
else if(currchar == "3") line = dolines(three,20)
else if(currchar == "4") line = dolines(four,20)
else if(currchar == "5") line = dolines(five,20)
else if(currchar == "6") line = dolines(six,20)
else if(currchar == "7") line = dolines(seven,20)
else if(currchar == "8") line = dolines(eight,20)
else if(currchar == "9") line = dolines(nine,20)
else line = dolines(currchar,20);
}
..code to ouput line[] array..
}
function dolines(currchar,nl)
{
for(i=0; i<=nl; i++) {
line[i] += currchar[i];
}
return line;
}
or if there's an even better way someone can think of doing this..?