#!/usr/local/bin/perl -w # Produce Files from Templates using wwwalias for aliases # makeform TEMPLATE REALFILE OPTIONS # # Recognize following special commands # {name} {value} {short} {full} {browse} # {loopindexone} which starts at 1 not 0 in numbering # {loopindexzero} which starts numbering at zero # {elementcount} increments by one each time encountered starting at zero # It records value before incrementing # {increment} increments {elementcount} without outputting # {length} which is total number of items # {select} {type} {othertype} # {browselist} # {browsetype} # {startloop} (or {loop} ) {endloop} # # If skip: key is set, then skip this option if skip value == REALFILE name # &readalias("wwwalias"); # %procoptvocab = ( "name",0,"value",0,"short",0,"full",0,"browse",0,"skip",0,"type",0, "contd",0, "html",0,"endhtml",0); # $globalcount=0; &readopt($ARGV[2]); # $list1=$ARGV[0]; open(TEMPLATEFILE,"<".$list1) || die("\nSorry couldn't open ",$list1,"\n"); $realfile=$ARGV[1]; open(REALFILE,">".$realfile) || die("\nSorry couldn't open ",$realfile,"\n"); @data=; # $skiptest = 'full'; $skiptest1 = 'full'; $skiptest = 'partial' if( $realfile eq 'OptionsFrame1.html' || $realfile eq 'FullOptionsFrame1.html' ); $skiptest = 'partial' if( $realfile eq 'Mainaddon' ); $skiptest1 = 'fullonly' if( $realfile eq 'OptionsFrame1.html' ); # # Set Template Command Variables $classwww{"endloop" }= -2; $classwww{"startloop"} = -1; $classwww{"loop"} = -1; $classwww{"name"} = 1; $classwww{"value"} = 2; $classwww{"short"} = 2; $classwww{"full"} = 2; $classwww{"browselist"} = 3; $classwww{"select"} = 4; $classwww{"loopindexone"} = 5; $classwww{"length"} = 6; $classwww{"type"} = 7; $classwww{"othertype"} = 11; $classwww{"loopindexzero"} = 8; $classwww{"elementcount"} = 9; $classwww{"optionformcount"} = 10; $classwww{"quickoptionformcount"} = 12; $classwww{"increment"} = 13; $classwww{"browsetype"} = 14; # $elementcount =0; $optionformcount=0; $quickoptionformcount=0; # $loopsize=$globalcount; $length = 0; $lengthfont = 0; $lengthcolor = 0; for($looping=0; $looping<$globalcount ;$looping++) { $key = $keytouse[$looping]; $actualpos{$key} = $optionformcount; $quickactualpos{$key} = -1; if(defined($skip{$key}) ) { next if( $skip{$key} eq $skiptest ); next if( $skip{$key} eq $skiptest1 ); } unless( defined($skip{$key}) && ($skip{$key} eq 'fullonly') ) { $quickactualpos{$key} = $quickoptionformcount; $quickoptionformcount +=3; ++$quickoptionformcount if(defined($browse{$key})); } $optionformcount +=3; ++$optionformcount if(defined($browse{$key})); ++$length; ++$lengthfont if( defined($type{$key}) && ($type{$key} =~ m%font%) ); ++$lengthcolor if( defined($type{$key}) && ($type{$key} =~ m%color%) ); } # # Loop over template lines $lasti=@data; # PRINTWWW1: for($i=0;$i<$lasti;$i++) { $looping = -1; $key = 'Error'; # PRINTWWW2: for($loop=$i; $loop < $lasti ; $loop++) { $end=$data[$loop]; chomp($end); $lineacc=''; $selected = 1; $selected = 0 if($looping >= $loopsize); while($end) { if( &curlyscan($end) ) { $lineacc .= $begin; $testwww=$classwww{$tag}; if( $testwww == -1 ) { # startloop ++$looping; $key = $keytouse[$looping]; undef($browsefile); while( ) { last unless(defined($skip{$key}) ); last unless( ($skip{$key} eq $skiptest) || ($skip{$key} eq $skiptest1) ); ++$looping; last if( $looping >= $loopsize ); $key = $keytouse[$looping]; } next PRINTWWW2; } if( $testwww == -2 ) { # endloop goto PRINTWWW2 if( $looping < $loopsize-1 ); $i=$loop; next PRINTWWW1; } next PRINTWWW2 unless $selected; $lineacc .= $key if( $testwww == 1); $lineacc .= eval( '$'.$tag.'{"'.$key.'"}' ) if( $testwww == 2 ); if( $testwww == 3 ) { $browsefile = $browse{$key}; next PRINTWWW2 unless defined($browsefile); if( $browsefile =~ m%^top% ) { $actualbrowsefile = $browsefile; ++$elementcount; print REALFILE < EOF } else { open(BROWSE,"<".$browsefile) || die("\nSorry couldn't open ",$browsefile,"\n"); print REALFILE $lineacc,"\n" if($lineacc); $lineacc=''; while($browseline = ) { chomp($browseline); print REALFILE "