autowatch = 1;
inlets = 1;
outlets = 3;
////sets the variables and patterns for the text
var cr = "cr"
var counter = 0;
var lineLength = 5;
var lineNum = 0;
var pastFirstLine = false;
var patternNumberOne = new Array(3,6,3);
var patternNumberTwo = new Array(3,3);
var patternNumberThree = new Array(5,5);
var patternNumberFour = new Array(7,7);
var patternNumberFive = new Array(4,6,8,6);
var patternNumberSix = new Array(3,5,7,1,7,5);
var patternNumberSeven = new Array(1,1,7,1,1,7,1);
var patternNumberEight = new Array(4,7,4);
var patternNumberNine = new Array(7,3,3,3);
var patternNumberTen = new Array(7,8,8);
var patternNumberEleven = new Array(4,4,4,6,4,4,4);
var whichPattern = new Array();
////function to choose one of the paterns at random
////sets the global variable whichPattern
function choosePattern(){
var rndNumber = Math.floor(Math.random()*10)+1;
switch(rndNumber){
case 1:
whichPattern = patternNumberOne;
//return whichPattern;
break;
case 2:
whichPattern = patternNumberTwo;
//return whichPattern;
break;
case 3:
whichPattern = patternNumberThree;
//return whichPattern;
break;
case 4:
whichPattern = patternNumberFour;
// whichPattern;
break;
case 5:
whichPattern = patternNumberFive;
// whichPattern;
break;
case 6:
whichPattern = patternNumberSix;
// whichPattern;
break;
case 7:
whichPattern = patternNumberSeven;
// whichPattern;
break;
case 8:
whichPattern = patternNumberEight;
// whichPattern;
break;
case 9:
whichPattern = patternNumberNine;
// whichPattern;
break;
case 10:
whichPattern = patternNumberTen;
// whichPattern;
break;
default:
whichPattern = patternNumberEleven
}
}
///function gets input from a text file
function textLineWriter(){
////creates an array from the arguments passed to it<---possible without array?
a = arrayfromargs(arguments);
b = -1;
///// choose a pattern by calling a function that chooses an array to work from
choosePattern();
////as long as the arguments are not null, it compares the pases through to the length of
////the first line (always five), if it matches 5 it increments b to 0 and uses the value
///of that index to be the line length outputting a carriage return and html break.
while (a.length > 0){
if (counter == lineLength){
lineNum += 1;
b += 1;
if (b==whichPattern.length){
b=0;
}
lineLength = whichPattern[b];
counter = 0;
outlet (0, "
");
outlet(0, cr);
}
////If it is the first line double break
if (lineNum == 1){
outlet(0, "
");
outlet(0, cr);
}
///sets current word to the first element in the aray and puts it out to a text object
currentWord = a.shift();
outlet (0, currentWord.toString());
counter+=1;
}
////resets counter and linelength to 5
counter = 0;
lineNum = 0;
lineLength = 5;
//post(a + counter + lineLength);
}