shortyfw06 has asked for the wisdom of the Perl Monks concerning the following question:
The following code creates a specified number of optionmenus and stores the optionmenu data in variables. I need to use the stored data for several things. For example, I need to know the number of different combinations stored, ie. PW -45, PW 0, PW 45, PW 90, 8HS 0 = 5 combinations. I also need to know the number of different materials stored, ie. PW -45, PW 0, PW 45, PW 90, 8HS 0 = 2 different materials. Finally, I need to know the thickness of each different combination, ie. 2*(PW 0 0.0077)= 0.0154, etc. Can someone please help get me pointed in the right direction? <\p>
use Tk; use Cwd; ###################################################################### +##################### # GUI Building ###################################################################### +##################### # Create Main Window my $mw = new MainWindow; my $lam_num; my $row=1; my $column=1; my $lam_mat_frm = $mw -> Frame(); $lam_mat_frm->grid(-row=>$row, -column=>$column,-columnspan=>6); my $lam_num_lab = $lam_mat_frm -> Label(-text=>"Input the number of pl +ies in the laminate.", -font=>"ansi 10 bold"); $lam_num_lab->grid(-row=>$row, -column=>$column); $column++; my $lam_num_ent = $lam_mat_frm -> Entry(-textvariable=> \$lam_num); $lam_num_ent->grid(-row=>$row, -column=>$column); $column++; my $lam_data_button = $lam_mat_frm->Button(-text=>"Input Laminate Data +", -command=> \&input_lam_data); $lam_data_button->grid(-row=>$row, -column=>$column); MainLoop; sub input_lam_data { $row=4; $column=2; my @lam_mat_t_lab = ( 'Material', 'Thickness', 'Orientation', ); my $n = 1; for my $label (@lam_mat_t_lab) { $mat_lab{$n} = $lam_mat_frm -> Label (-text=> $label, -font=>"ansi 8 bold"); $mat_lab{$n}->grid(-row=>$row, -column=>$column); $column=$column+1; }; my %ply_lab; $n = 1; $row=5; do { $column = 1; $ply_lab{$n} = $lam_mat_frm -> Label (-text=>"Ply $n", -font=>"ansi 8 bold"); $ply_lab{$n}->grid(-row=>$row,-column=>$column); $row = $row+1; $n = $n+1; } until ($n == $lam_num+1); # Create Material Optionmenus my @mats = ("PW","8HS","Tape"); my %mat_optmen; $n = 1; $row=5; $column=2; do { $mat_optmen{$n} = $lam_mat_frm -> Optionmenu(-options => \@mat +s, -variable => \$mat{$n}); $mat_optmen{$n}->grid(-row=>$row,-column=>$column); $row=$row+1; $n = $n + 1; } until ($n == $lam_num+1); # Create Thickness Optionmenus my @ts = ("0.0077","0.0147","0.0054"); my %t_optmen; $n = 1; $row=5; $column=3; do { $t_optmen{$n} = $lam_mat_frm -> Optionmenu(-options => \@ts, -variable => \$t{$n}); $t_optmen{$n}->grid(-row=>$row,-column=>$column); $row=$row+1; $n = $n + 1; } until ($n == $lam_num+1); # Create Orientation Optionmenus my @orts = ("-45","0","45","90"); my %ort_optmen; $n = 1; $row=5; $column=4; do { $ort_optmen{$n} = $lam_mat_frm -> Optionmenu(-options => \@ort +s, -variable => \$ort{$n}); $ort_optmen{$n}->grid(-row=>$row,-column=>$column); $row=$row+1; $n = $n + 1; } until ($n == $lam_num+1); my $print_button = $lam_mat_frm->Button(-text=>"Print BJSFM Input +File", -command=> \&print_input_file); $print_button->grid(-row=>$row,-column=>1); } sub print_input_file { }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Create an array from Optionmenu variables
by Anonymous Monk on Mar 13, 2012 at 05:45 UTC | |
by Anonymous Monk on Mar 13, 2012 at 06:06 UTC | |
by shortyfw06 (Beadle) on Mar 13, 2012 at 14:51 UTC | |
by Anonymous Monk on Mar 13, 2012 at 14:56 UTC | |
by shortyfw06 (Beadle) on Mar 13, 2012 at 14:59 UTC | |
by zentara (Cardinal) on Mar 13, 2012 at 16:53 UTC | |
by Anonymous Monk on Mar 13, 2012 at 15:42 UTC | |
|
Re: Create an array from Optionmenu variables
by zentara (Cardinal) on Mar 13, 2012 at 16:51 UTC |