# TODO
# what happens when files are not writable?
-# delete button
-# field size information
-# check for maximum value
# DONE
# do not include wrong type, different specfile
# nested include graphic
# cannot inherit from files with the wrong specification!
# do not accept "..." as input file
+# delete button
+# field size information
+# check for maximum value
my $me = "cgitest.pl";
my $xmlfile = $confDir . "/" . $xmlfileName;
# check if all files in the ancestry really exist!
- unless (-e $xmlfile) {
+ unless ( -e $xmlfile ) {
print "<p>You are trying to include a file that does not exist</p>";
print "<p>";
- print "<strike>".$xmlfileName."</strike>"."->"
+ print "<strike>"
+ . $xmlfileName
+ . "</strike>" . "->"
. join( "->", @ancestryList ) . "->"
. $setfileName;
print "</p>";
return;
}
-
my $xmltree;
if ( $xmlfile eq $setfile ) {
$xmltree = $settree;
my $configFile = $_[0];
- print "<p>selected config file</p>";
+ print "<h3>selected config file</h3>";
print "<p>";
-
+
print_fileSelector( $configFile, "fileSelector", "loadFile()" );
print
"<input type='button' onclick='loadFile()' value='reload file' class='stdbutton'>";
"<input type='button' onclick='deleteFile()' value='delete file' class='stdbutton'>";
print "</p>";
-
-
- print "<p>create new config file</p>";
+
+ print "<h3>create new config file</h3>";
print "<p>";
+ print "<table><tr>";
+ print "<td>filename</td><td>based on specification</td><td></td>";
+ print "</tr>";
+ print "<tr>";
+ print "<td>";
print "<input type='text' value='' id='newFileName'>";
+ print "</td><td>";
print_specSelector();
- print "<input type='button' onclick='createFile()' value='create file' class='stdbutton'>";
-
- print "</p>";
-
+ print "</td><td>";
+ print
+"<input type='button' onclick='createFile()' value='create file' class='stdbutton'>";
+ print "</td></tr></table>";
+ print "</p>";
# print "<table>";
# print "<tr><td>";
my $isHeritageFrom = $field->findvalue("./\@isHeritageFrom") || "";
my $readOnlyFlag = 0;
my $fieldValue = $field->findvalue("./\@value");
- my $fieldDescr = prepare_text(
+ my $fieldSize =
+ $spectree->findvalue( "/MAPS/register[\@name='"
+ . $registerName
+ . "']/field[\@name='"
+ . $fieldName
+ . "']/\@size" )
+ || "n/a";
+ my $fieldDescr = prepare_text(
$spectree->findvalue(
"/MAPS/register[\@name='"
. $registerName
|| "n/a"
);
+ my $maxFieldVal = 2**$fieldSize;
+ my $sizeInfo =
+ sprintf(
+ "Field contains %d bits, possible values: 0-%d (0x0-0x%x)\n\n",
+ $fieldSize, $maxFieldVal, $maxFieldVal );
+
+ $fieldDescr = $sizeInfo . $fieldDescr;
+
unless ( $isHeritageFrom eq "" ) {
$fieldDescr =
"Field was inherited from $isHeritageFrom\n\n" . $fieldDescr;
}
}
print "</tr>";
+ if ( ( any2dec($fieldValue) < 0 )
+ or ( any2dec($fieldValue) > $maxFieldVal ) )
+ {
+ print "<tr class='fieldError'><td colspan = 4 align='center'>!!!Above value not in allowed range!!!</td></tr>"; # just debug
+ }
}
print "</table>";
%FORM;
}
+sub any2dec { # converts numeric expressions 0x, 0b or decimal to decimal
+
+ my $argument = $_[0];
+
+ #print "any2dec input argument $argument\n";
+
+ if ( $argument =~ m/0[bxBX]/ ) {
+ return oct $argument;
+ }
+ else {
+ return $argument;
+ }
+}
+
sub printJavaScripts {
####### javascript function land ################