Hello,
I have a programming question that is best explained by giving a working example.
OBJECTIVE: Have the flows and the duration of each one as given by getFlowStatisticsDuration().
The Flow:
list_keys= newList();
list_values= newList();
duration= getFlowStatisticsDuration();
size = length(getFlowStatisticsDuration()); //size may vary from one run from another run.
list_keys=getMapKeys(getFlowStatisticsDuration());
list_values=getMapValues(getFlowStatisticsDuration());
a=0;
while (a < size){
list_keys[a];
list_values[a];
a=a+1; // no a++ accepted. Weird.
{
Once this is set up, all I need is to write the file with the pairs built in the "while" loop.
This is the trivial part.
Please pardon my ignorance from this point on.
MY SOLUTION:Probably not that smart I'd say:
in the text in the Write to File i blindly define the entries as follows:
{list_key[0]} {list_values[0]}
...
{list_key[n]} {list_values[n]} Note: "n" may be smaller or greater than variable size above
ANALYSIS:
The above method of defining the output to be "printed" may not bring all entries or will have too many of them predefined in this case, a lot of {error} will be printed since predefined entries are more them the real data collected.
QUESTION:
Is there a better way to write the output in such a way that it could be controlled by the variable size?
In other words, no need to predefine the number of
{list_key[0]} {list_values[0]}
...
{list_key[n]} {list_values[n]}
and make it happen programmatically?
Thanks
Husky
Simple programming question
Moderator: Martin
Simple programming question
"Basic research is what I'm doing when I don't know what I'm doing"
Re: Simple programming question
Hi,
I would prepare the entire text in the script.
Following script should work:
and then just use action Write to File: {output}.
Regards,
Martin
I would prepare the entire text in the script.
Following script should work:
Code: Select all
stats=getFlowStatisticsDuration();
keys=getMapKeys(stats);
output="";
for (key in keys)
{
output = output + key + ": " + stats[key] + "\n";
}
Regards,
Martin
Re: Simple programming question
Martin,
Thanks for thr reply.
I did not know that this could be done inside the Script. I though once you have everything squared out in the Script, the only way to proceed to the output would be adapting the Write to File in the idiot way I was doing it.
Your example is PERFECT. Will save me a lot of time.
Thank You and have a Happy New Year
Husky
Thanks for thr reply.
I did not know that this could be done inside the Script. I though once you have everything squared out in the Script, the only way to proceed to the output would be adapting the Write to File in the idiot way I was doing it.
Your example is PERFECT. Will save me a lot of time.
Thank You and have a Happy New Year
Husky
"Basic research is what I'm doing when I don't know what I'm doing"