xxxxxxxxxx
var textArr1, textArr2, textArr3, textArr4;
var newTextArr1, newTextArr2, newTextArr3, newTextArr4;
function preload(){
textArr1 = loadStrings("code_perlin_noise.txt");
textArr2 = loadStrings("code_colorful_flow_IV.txt");
textArr3 = loadStrings("code_teleporting_dots.txt");
textArr4 = loadStrings("mySketch.txt");
}
// Note: we could delete users' comments and all the strings in the code
// find things between /**/ and the line starts with //, delete them
// find things between "" and ''
// does user specified variables matter? perhaps the amount matters in the future?
function setup(){
//newTextArr1 = cleanText(textArr1);
newTextArr2 = cleanText(textArr2);
//newTextArr3 = cleanText(textArr3);
//newTextArr4 = cleanText(textArr4);
}
function cleanText(textArr){
console.log(textArr);
var wholeText = "";
// iterate through text array
for (var i=0; i<textArr.length; i++){
wholeText += textArr[i];
wholeText += "\n";
}
console.log(wholeText);
// // replace whats after // with ""
// var newWholeText = wholeText.replace(/\/\/(.*)$/gm, "");
// console.log(newWholeText);
// // replace between /* and */ (even if multiline) with ""
// var newWholeText1 = newWholeText.replace(/\/\*(.*)\*\//gs, "");
// console.log(newWholeText1);
// // replace between " and " (even if multiline) with ""
// var newWholeText2 = newWholeText1.replace(/"(.*)"/gs, "");
// console.log(newWholeText2);
// // replace between ' and ' (even if multiline) with ""
// var newWholeText3 = newWholeText2.replace(/'(.*)'/gs, "");
// console.log(newWholeText3);
var newWholeText = wholeText.replace(/\/\/(.*)$/gm, "").replace(/\/\*(.*)\*\//gs, "").replace(/"(.*)"/gs, "").replace(/'(.*)'/gs, "");
console.log(newWholeText);
var newTextArr = newWholeText.split("\n");
console.log(newTextArr);
return newTextArr;
}