Simple programming question
Posted: 27 Dec 2016 18:30
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
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