This isn't really the place, but I used Graal script for something I did at work:
HTML Code:
function onCreated()
{
//Remove the current values
for (temp.currentVar: getstringkeys("this."))
unset("this."@ temp.currentVar);
this.allowedNetworks = {"Orange", "O2", "T-Mobile", "Vodafone"};
this.numberLength = 11;
//Load the file with the text information stored
temp.fileContent.loadlines("temp/myData.txt");
for (temp.currentVar: temp.fileContent)
{
//Load the arrays from the file
temp.callDetails = temp.currentVar.tokenize("=");
temp.mobileDetails = temp.callDetails[1].tokenize(",");
//Organize the arrays data
temp.csaName = temp.callDetails[0].substring(4);
temp.mobileNumber = temp.mobileDetails[0].substring(1);
temp.mobileOperator = temp.mobileDetails[1];
temp.messageSent = temp.mobileDetails[2].substring(0, 1);
//Record all the repeated fields information.
this.calculateData(temp.csaName, {"mobileNumbers", "mobileOperators", "sentMessage"}, {temp.mobileNumber, temp.mobileOperator, temp.messageSent});
this.totalCalls++;
this.("totalCalls_" @ temp.csaName)++;
}
//Finally draw the statistics!
this.drawStatistics();
}
function calculateData(csaName, callNames, callDetails)
for (temp.callDetail: temp.callDetails)
{
//Don't do the statistics if the information isn't correct!
if (this.allowedNetworks.index(temp.callDetails[1]) == -1)
continue;
if (temp.callDetails[0].length() != this.numberLength)
continue;
temp.varName = temp.callNames[temp.callDetails.index(temp.callDetail)];
switch(temp.varName)
{
//Check for multiple callers
case "mobileNumbers":
if (this.allNumbers.index(temp.callDetail) != -1)
this.repeatedCalls++;
this.allNumbers.add(temp.callDetail);
break;
//Add all the calls done by a mobile operator
case "mobileOperators":
this.("calls_"@ temp.callDetail)++;
break;
//Add all messages sent
case "sentMessage":
if (temp.callDetail)
{
this.("messagesSent_"@ temp.csaName)++;
this.("messagesSent_"@ temp.callDetails[1])++;
this.messagesSent++;
}
break;
}
}
function drawStatistics()
{
//Finally output the information
temp.outputMessages = {
"Mobile Statistics:",
format(_("Total SMS Calls: %d"), this.totalCalls),
format(_("Total Messages Sent: %d"), this.messagesSent),
format(_("Total Not Sent: %d"), abs(this.totalCalls - this.messagesSent)),
(this.repeatedCalls > 0? format(_("Repeated Calls: %d"), this.repeatedCalls): ""),
};
for (temp.currentOperator: getstringkeys("this.messagesSent_"))
if (this.allowedNetworks.index(temp.currentOperator) != -1)
temp.outputMessages.add(format(_("%s Sent: %d / %d"), temp.currentOperator, this.("messagesSent_"@ temp.currentOperator), this.("calls_"@ temp.currentOperator)));
else
if (this.("messagesSent_"@ temp.currentOperator) > this.lastSent[1])
this.lastSent = {temp.currentOperator, this.("messagesSent_"@ temp.currentOperator)};
temp.outputMessages.add(format(_("Most Sent: %s [%d]"), this.lastSent[0], this.lastSent[1]));
for (temp.currentMessage: temp.outputMessages)
echo(temp.currentMessage);
}
hehe