IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 26, 2006, 10:40:55 AM (20 years ago)
Author:
eugene
Message:

adding menu hierarchy

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippMonitor/generate

    r8980 r8984  
    22
    33$VERBOSE = 0;
     4
    45if ($ARGV[0] eq "-v") { $VERBOSE = 1; shift @ARGV; }
    56if (@ARGV != 3) { die "generate (schema) (template) (output)\n"; }
     
    1819    close (FILE);
    1920
     21    &init_key ("MENU");
     22    &init_key ("STYLE");
    2023    &init_key ("TABLE");
    2124    &init_key ("TITLE");
    2225    &init_key ("FILE");
     26
    2327    &init_key ("FIELDS");
    2428
     
    5458        }
    5559    }
     60
     61    # check on keys
     62    &check_key ("MENU", "ipp.menu.dat");
     63    &check_key ("STYLE", "ipp.css");
     64    &check_key ("TABLE", "");
     65    &check_key ("TITLE", "");
     66    &check_key ("FILE", "");
     67
    5668    # define query string, add to keypairs
    5769    &define_query_fields;
     
    192204            if ($value[$i] ne "") { die "key is multiply defined\n"; }
    193205            $value[$i] = $value;
     206            if ($VERBOSE) { print STDERR "setting $key = $value\n"; }
    194207            return;
    195208        }
    196209    }
     210}
     211
     212sub check_key {
     213    my ($i);
     214    my ($key)     = $_[0];
     215    my ($default) = $_[1];
     216
     217    for ($i = 0; $i < @key; $i++) {
     218        if ($key eq $key[$i]) {
     219            if ($VERBOSE) { print "found $key: $key[$i]  -- $value[$i] (def: $default)\n"; }
     220            if (($default eq "") && ($value[$i] eq "")) { die "missing value for required key $key[$i]\n"; }
     221            if ($value[$i] eq "") { $value[$i] = $default; }
     222            return;
     223        }
     224    }
     225    die "unknown key $key\n";
    197226}
    198227
     
    200229    my ($i);
    201230    for ($i = 0; $i < @key; $i++) {
    202         # if ($VERBOSE) { print "$key[$i]  -- $value[$i]\n"; }
     231        if ($VERBOSE) { print "$key[$i]  -- $value[$i]\n"; }
    203232        if ($line =~ m|\$$key[$i]|) {
    204233            if ($value[$i] eq "") { die "missing value for required key $key[$i]\n"; }
Note: See TracChangeset for help on using the changeset viewer.