DOCUMENTATION

SYNOPSIS

Perl package: param_flow_green.pm 
AUTHOR: Juan Lorenzo
DATE: Aug 3 2017 

DESCRIPTION: 
V 0.0.1 Aug 3 2017
V 0.0.2 July 23 2018
V 0.0.3 Oct 10 2018 allows numeric values = 0
V 0.0.4 April 2021 delete_selection can delete
'all' at once

USED FOR: 

BASED ON:
 param_flow_green.pm
private hash_ref
w  for widgets

sub _get_good_length4item

sub _get_names_aref

sub _get_values_aref

find reference for array of values

sub _set_good_labels4item

Oct 10. 2018 allow numbers=0 

sub _set_good_values4item

Set good values privately for a single item (program name)
within a flow
only non-empty values will be used

sub clear

clear from memory any existing values in the namespace
= 31

sub clear_flow_items_version_aref

clear version array reference

sub delete_selection

delete parameter names and values
from one  selected item at a time
as well as all at once

sub first_idx

first usable index is set to 0

sub get_check_buttons_settings

my ($i,$j, $length); my @on_off; my @values_aref;

 		@values_aref 	= @{@{$param_flow_green->{_checkbuttons_aref2}}[$index]};
 		$length			= scalar @values_aref;

   		print("param_flow_green,get_check_buttons_settings: is @values_aref\n");

  		#for ($i=1,$j=0; $i < $length; $i=$i+2,$j++ ) {
  		for ($i=0; $i < $length; $i++ ) {
    		#$values[$j]  = $values_aref[$i]; 
    			#print("param_flow_green, get_check_buttons_settings :index $j values: $values[$j]\n");
     	if($values_aref[$i] eq $nu || ) {
     	  	$on_off[$i]     = $off;
		  	# print(" 1. param_flow_green, get_check_buttons_settings,$on_off[$i]\n");
     	}
     	else {
       		$on_off[$i]     = $on;
		    # print(" 2. param_flow_green, get_check_buttons_settings,$on_off[$i]\n");
     	}
     	# print("param_flow_green: get_check_buttons_settings :index $i setting $nu is: $on_off[$i]\n");
   		}

sub get_flow_index

get current program index 
 

sub get_flow_prog_names_aref

extract sequential program names in flow 

sub get_flow_items_version_aref

o/p is array ref of the version of each program name

sub get_good_labels_aref2

sub get_good_values_aref2

sub get_names_aref

sub get_num_good_labels_aref

sub get_num_good_values_aref

sub get_max_index

Number of programs in the flow +1
Should increment every time that add2flow is run
in a superflowstack_names_aref2

sub get_num_items

Number of programs in the flow
Should increment every time that add2flow is run
in a superflowstack_names_aref2

sub get_values_aref

Collect all the values, whether empty or not

sub insert_selection

delete parameter names and values
of on one  selected item

sub length

last item number (not last index) 
last item number is equivalent to length
because values and labels are stored in the same 
array, the length is twice the number of values or
labels individually.
Hence we also have subroutines to extract and set
"half-lengths" with respect to the stored configuration 
parameters.

sub set_check_buttons_settings

set check_buttons by user from outside

sub set_flow_items_version_aref

i/p is array ref of the version of each program name

sub set_insert_start

move paramter names and values
of one selected item into another
space

sub set_insert_end

move paramter names and values
of one selected item into another
space

sub set_flow_index

select an item from which to extract data

     			print("param_flow_green, set flow_index, prog name is @{$param_flow_green->{_prog_names_aref}}[$index]\n");
 

sub set_names_aref

sub set_param_index

set single index

sub set_good_labels

select names with values

sub set_good_values

find good values for ALL programs in flow

sub set_good_labels4item

sub set_good_values4item

work on finding good values for one item

sub set_param_value

Store single value

sub set_values_aref

Store values

sub stack_checkbuttons_aref2

array of arrays
One array if checkbuttons for each item
DB
#for (my $i=0; $i<=$index;$i++) {
  #print("param_flow_green,checkbuttons_aref,@{@{$param_flow_green->{_checkbuttons_aref2}}[$i]} index $i\n");
#}
   #print("param_flow_green, checkbuttons_aref2, num_items4checkbuttons $param_flow_green->{_num_items4checkbuttons}\n");

sub stack_flow_item

i/p is scalar ref to a program name
keep count and increment the number of items
encapsulate internal counters and array
from the array shared among the package subroutines 

count items at start in case we don't return to the subroutine
later
    print("param_flow_green, stack_flow_item @{$param_flow_green->{_prog_names_aref}}, num_items $param_flow_green->{_num_items}\n");
	 print("param_flow_green, stack_flow_item, index: $index\n");

sub stack_names_aref2

i/p array ref for values in a program
an array of arrays is created, one array for each item
DrBN

    #print("param_flow_green, names_aref2, num_items4names $param_flow_green->{_num_items4names}\n");

#print("param_flow_green,names_aref,$names[$index],item $index\n");
# print("param_flow_green, stack_names_aref2, names in program# $index are @{$names[$index]}[0]\n");
for(my $i = 0; $i <=$index; $i++) {
  	print("param_flow_green,stack_names_aref2, cumulative first names are:  @{$names[$i]}[0], prog num =$i\n");
}

sub stack_values_aref2

i/p array ref for values in a program
an array of arrays is created, one array for each item

DB #for (my $i=0; $i<=$index;$i++) { # print("param_flow_green,values_aref2,@{@{$param_flow_green->{_values_aref2}}[$i]} index $i\n"); #} #print("param_flow_green,values_aref2,num_items=$param_flow_green->{_num_items}\n"); # print("param_flow_green,values_aref2, index $index\n");

sub view_data

Data viewer for debugging
  print("B4  delete: names are  $param_flow_green->{_names_aref2}\n");    # ref_Array
  print("B4  delete: names are  @{$param_flow_green->{_names_aref2}}\n");     # [ref_array0 ref_array1 .... 
  print("B4  delete: names are  @{$param_flow_green->{_names_aref2}}[0]\n");  # ref_array0

  print("B4  delete: names are  @{$param_flow_green->{_names_aref2}}[1]\n"); #ref_array1
    
  print("B4  delete: names are  @{@{$param_flow_green->{_names_aref2}}[0]}\n"); # all names in ref_array 0 
  print("B4  delete: names are  @{@{$param_flow_green->{_names_aref2}}[1]}[0]\n"); # first name  in ref_array 
  print("param_flow_green,view_data: list for each item\n");