Cmenu
view release on metacpan or search on metacpan
}
# ---< menu 4 >----------------------------------------------------
sub menu04 {
&menu_button_set(1,"Select"); # switch on a button labelled "Help"
&menu_button_set(2,""); # switch on a button labelled "Help"
&menu_button_set(3,""); # switch on a button labelled "Help"
&menu_init("Data Fields","Lists a number of data fields, left aligned. You can press a letter to jump to a particular item");
# Here are the option calls
for($i=0;$i<=6;$i++) {
&menu_item($data[$i],$label[$i],4);
}
for($i=7;$i<=9;$i++) {
if($data[$i]==1) {&menu_item($label[$i],"Sex",4); }
}
&menu_item("------------","Drinks",9);
for($i=10;$i<=14;$i++) {
if($data[$i]==1) {&menu_item($label[$i],$i-9,8,$label[$i]); }
}
$sel=&menu_display("Choose a Field");
chop($sel);
if($sel eq "%EMPTY%") {
$sel="You pressed the <EXIT> function Key";
} else {
$sel="You selected the <$sel> field";
}
&menu_show("Selected Item",$sel,HELP);
}
# ---< menu 5 >----------------------------------------------------
sub menu05 {
&menu_button_set(1,"Select"); # switch on a button labelled "Help"
&menu_button_set(2,""); # switch on a button labelled "Help"
&menu_button_set(3,""); # switch on a button labelled "Help"
&menu_init("Data Fields","Lists a number of data fields, right aligned. You can press a letter to jump to a particular item");
# Here are the option calls
for($i=0;$i<=4;$i++) {
&menu_item($data[$i],$label[$i],5);
}
&menu_item($data[6],$label[6],5);
for($i=7;$i<=9;$i++) {
if($data[$i]==1) {&menu_item($label[$i],"Sex",5); }
}
$sel=&menu_display("Choose a Field");
chop($sel);
if($sel eq "%EMPTY%") {
$sel="You pressed the <EXIT> function Key";
} else {
$sel="You selected the <$sel> field";
}
&menu_show("Selected Item",$sel,HELP);
}
# ---< menu 6 >----------------------------------------------------
# This option does a word count on the script, holds a processing popup for a while
# and then displays the results
sub menu06 {
&menu_button_set(1,"Accept");
&menu_button_set(2,"");
&menu_button_set(3,"Reject");
&menu_popup("Counting the number of words in this script");
system("wc demo >yum");
open(IN,"<yum");
while(<IN>) {
chop;
($wcl,$wcw,$wcb,$wcf)=split;
}
close(IN);
system("rm yum");
system("sleep 2");
$yum="\n Line count = $wcl\n Word count = $wcw\n Byte count = $wcb\nfor file $wcf\n";
&menu_popup();
$yum="This is the results of calling wc on file demo although it is not formated properly it may look half decent".$yum;
# Here we show how to catch the results of a popup screen
$sel=&menu_show("Confirm Word-count",$yum,WARN);
&menu_button_set(1,"Continue");
&menu_button_set(3,"");
if($sel eq "YES") {
&menu_show("Word Count Accepted",$yum,HELP);
} else {
&menu_show("Word Count Rejected",$yum,ERROR);
}
}
# ---< menu 7 >----------------------------------------------------
sub menu07 {
&menu_button_set(1,"Edit or Accept");
&menu_button_set(2,"Help");
&menu_button_set(3,"Accept");
&menu_init("Edit Alpha Fields","Lists a number of data fields, left aligned. You can press a letter to jump to a particular item. Alphabetic fields can be edited","edit.txt");
# Here are the option calls
for($i=0;$i<=6;$i++) {
if($i==6) {
&menu_item($data[$i],$label[$i],4);
} else {
&menu_item($data[$i],$label[$i]." (edit)",6,$i,"25 0 0 ");
}
}
$sel=&menu_display("Editing Text Fields");
&menu_button_set(1,"Continue");
&menu_button_set(2,"");
&menu_button_set(3,"");
@x=split(/$Cmenu::menu_sep/,$sel);
if($#x==0) {
&menu_show("No fields Changed","No fields have been changed",ERROR);
} else {
$text="Text fields have been amended\n";
for($i=1;$i<=$#x;$i++) {
# Breakout field label and new data
($field,$newdata)=split(/$Cmenu::menu_sepn/,$x[$i]);
$text=$text." Field $field $label[$field] set to <$newdata>\n";
$data[$field]=$newdata;
}
$text=$text." Field 6 $label[6] remains unchanged as $data[6]";
&menu_show("Data edited",$text,WARN);
}
}
# ---< menu 8 >----------------------------------------------------
sub menu08 {
&menu_button_set(1,"Edit or Accept");
&menu_button_set(2,"Help");
&menu_button_set(3,"Accept");
&menu_init("Edit Numeric Fields","Lists a number of data fields, left aligned. You can press a letter to jump to a particular item. The Age field is numeric and can be edited","edit.txt");
# Here are the option calls
for($i=0;$i<=6;$i++) {
if($i==6) {
&menu_item($data[$i],$label[$i]." (edit)",7,$i,"3 0 0 ");
} else {
&menu_item($data[$i],$label[$i],4);
( run in 1.060 second using v1.01-cache-2.11-cpan-364913b4093 )