var names = new Array();
//add to your array
names.push("Add me");
//WHERE in the array is the item located
var fruits = ["Banana", "Orange", "Apple", "Mango"];
var a = fruits.indexOf("Apple"); //the "O" is CAPITAL!!
//the result of the above is a = 2
//to search backwards from end of array do this..
var a = fruits.lastIndexOf("Apple");
//the result of the above is a = 2
#####################################################
A LOOP TO BUILD AN ARRAY...
#####################################################
//loop through each item and build an array storing the domain index keys
while (ReplaceRange.getRow() <= lRow){
ReplaceRange = ReplaceRange.offset(1,0);
ReplaceRange.activate();
if (ReplaceRange.getValue() != "")
{
Logger.log("new Domain is " + ReplaceRange.getValue());
names.push(ReplaceRange.getValue());
}
}
#####################################################
A GENERAL FOR LOOP TO LOOP THROUGH EXISTING..
#####################################################
for (i=0; i < names.length; ++i)
{//this represents the first ("0") line of a multidimensional array
var SingleItem = names[i][0].toString().trim();
//this assigns a single item from the array to a variable
var SingleItem = names[i].toString().trim();
}
#####################################################
A FOR LOOP TO CHECK IF AN ARRAY CONTAINS AN ITEM
#####################################################
//loop through each item in the array of domain names
for (var i=0; i<names.length; i++)
{
Logger.log("The Single item is " + SingleItem);
Logger.log("The Array value is " + names[i]);
if (SingleItem == names[i])
{
//TRUE.. VARIABLE IS IN ARRAY
}
} //END of for loop
#####################################################
SINGLE LINE IF STATEMENT
#####################################################
var Name1 = (FormInfo[0][4] != "")?1:0;
Name1 = (FormInfo[0][5] != "")?Name1+1:Name1;
//This gets every value in a row, adds items to each element and then puts it back
//get every value in the sheet
//in potions 3 and 4 of the get range 1 = same row/colmum. The following example starts in the current row column B and goes over to the current row column F.
//(1,1,1,1) is A1 as a cell
//(1,1,1,3) is A1:C1)
var current = TwoSheet.getRange(TwoRange.getRow(), 2, 1, 5).getValues();
current[0][0] = current[0][0] + Business;
current[0][1] = current[0][1] + Lumber;
current[0][2] = current[0][2] + Refferal;
current[0][3] = current[0][3] + Name1;
current[0][4] = current[0][4] + Visitor1;
//rewrite the sheet back out
TwoRange = TwoSheet.getRange(TwoRange.getRow(), 2, 1, 5).setValues(current);
No comments:
Post a Comment