> Dear Mr Braun,
> Recently I cam across the perl script file you wrote sometime back
> ago to create NEC input files from parameterized physical
> descriptions. I will like to know how can I used it or run it?
> Thanks in advance.
>
> Regards,
> Boon Phing
Hello,
Below is a newer version of my script, which works around a Perl bug
and works with more versions of NEC.
Basically, it works like this:
All lines starting with "#" are stripped out of the input and given to
the Perl interpreter. Then all portions of the other lines within
curly braces "{}" are evaluated by the Perl interpreter, and the
result is substituted into the file.
So, input like this:
# $spacing = 0.71
GW 1 1 {$spacing} {-$spacing} {$spacing+5.0} ...
will become:
GW 1 1 0.71 -0.71 5.71 ...
The stuff after the # and between the {}s can be arbitrarily complex
Perl expressions.
Also, in the version below, blank lines and lines starting with '$'
are stripped out.
Doug Braun
#!/usr/bin/perl
# Improved version of "param" script, Jan 1998 D. Braun
$# = "%.6g"; # Set default printing frmat
$_definios = "";
whilef(m/^#/) //; # remove leading whitespace
s/\s*$//; # remove trailing whitespace
eval($_);
#$_definitions = $_definitions . $_ . ";"; # append to master list
}
elsif (m/^\$/ || m/^[ ]/ || m/^$/)
{
; # For old dumb NEC versions: filter out non-card lines:
# blank lines, '$' comment lines, etc.
}
else
{
# Look for {} expressions
chop $_;
while (m/{/)
{
# Remove and print the portion of the line before the {
s/^[^{]*{//; # Remove upto and including the bracket
$_s = $&;
chop $_s; # Remove the bracket
# Print $_s, one char at a time
# We do it this weird way to prevent "1.0"
# from being printed as "1"...
while (length($_s))
{
$_s =~ s/^.//;
$_s2 = $&;
print $_s2;
}
if(m/}/)
{
s/^[^}]*}//; # Chop off everything until the }
$_expression = $&;
chop $_expression;
}
else
{
$_expression = $_;
$_line = "";
}
# Process the expression
#print eval($_definitions . $_expression);
print eval($_expression);
}
# Print the rest of the line, one character at a time
# We do it this weird way to prevent "1.0" from being
# printed as "1"...
while (length($_))
{
s/^.//;
$_s = $&;
print $_s;
}
print "\n";
}
}
Received on Mon Mar 23 1998 - 09:56:20 EST
This archive was generated by hypermail 2.2.0 : Sat Oct 02 2010 - 00:10:38 EDT