-------Original Message-------
 
From: Rob Dixon
Date: Tuesday, November 04, 2003 5:23:17 PM
Subject: Re: $x .= $y suddenly breaks and does $x=$y instead!
 
Hi Richard.
 
Richard Heintze wrote:
>
> Sorry -- I was not quoting my own code precisely and I am using strict and warnings.
> I am using parenthesis. I attached the exact code for the subroutine below.
 
At the end of this post is my edited version of your program without line wraps.
It compiles fine as I have posted it, and there are no reasons that I can see
why your concatenation shouldn't work.
 
The problems that I have are:
 
- Your source layout allows a maximum line length of 196 characters.
It's unlikely that you know what your source is doing off-screen, even
if you think you do. Keep to something like an 80-character limit and
all of the bugs will be on-screen at once.
 
- Subroutines with more than two or three parameters are unlikely to be
called correctly. 'FormElements' has seven, and to make matters worse
there is a mixture of pass by value and pass by reference.
 
- There is a mixture of qq() delimiters within the same subroutine. (Square
bracket and pipe). It would be best to build these strings into a scalar
variable as soon as its parameters are known instead of strewing the code
with huge interpolated strings.
 
I suspect that the bug is in the call to this routine, but first tidy
up your code so that it /looks/ like it works. 'Here' documents
would help to organise your strings instead of having long
interpolated strings as subroutine parameters.
 
Post your subroutine call. I'll lay $5 that your bug is there :)
 
HTH,
 
Rob
 
 
 
# Reformatted source
#
sub FormElements {
 
   my ($me,
       $next,
       $ev_count,
       $curr_true, # integer array created in insert data
       $prob_innoc,
       $prob_guilt,
       $hidden) = @_;
 
   # The first time we view the Enter Probabilities page (display)
   # we have the option of specifing admissibility (the probability of the evidence being admissible in court)
   # and the probability the fact is true.
   #
   # When there are subsequent assertions or suspects, there is no need to allow the user to change this information
   # so we surpress the text edit box.
   #
   my $bReadOnly = !$me->bFirstSuspect(); # $me->{pass}==0 && $next==1; # Can the user change this? Yes, if this is the first
Suspect/Assertion.
   my $t3 = $me->{admissibility};
   my $admis = sprintf "%3d", $t3->[$ev_count];
 
   print
     ($me->bShowAdmissibility()?(qq[
       <TD ALIGN="CENTER" STYLE="font-family:serif; font-size:18px; font-weight: bold; background-color:#ffcc00">]
         .($bReadOnly?qq[$admis <INPUT class=debug READONLY TYPE=TEXT NAME=prob_admis$ev_count SIZE="2" VALUE="$admis" />]:qq[<INPUT
TYPE=TEXT NAME=prob_admis$ev_count SIZE="2" VALUE="$admis" />])
         ."</TD>"):"");
 
   print qq[<TD ALIGN="CENTER" STYLE="font-family:serif; font-size:18px; font-weight: bold; background-color:#ffcc00">];
 
   # older code: $me->{base_type}=~"Rank" || $me->{base_type}=~"RA" || $me->{base_type}=~"Compare Assertions"
   # old code: ($me->{base_type} == &case_constants::btCompareAssertions || $me->{base_type} == &case_constants::btRankSuspects)
 
   if ($me->MultiSuspectCase() && $bReadOnly) {
 
     # No input box here!
     my $t2 = @{$$curr_true}[$ev_count]; # This is so wierd. Why do I need to explicitly cast it?
     $t2 = sprintf "%3.3f", ($t2<=0?0:$t2);
 
     my $t3 = qq[<INPUT class=debug TYPE=TEXT NAME="prob_true$ev_count" VALUE="$t2" SIZE=2>];
     print $t2.$t3;
 
     # Why does not this concatenation work?
     $$hidden = $$hidden.qq[\n<TR class=debug><TD>prob_true$ev_count</TD><TD>$t3%</TD></TR>\n];
   }
   else {
     # Input box: user can alter this
     print qq[ <INPUT TYPE="TEXT" ID="prob_true$ev_count" NAME="prob_true$ev_count" SIZE="7"
MAXLENGTH="6">%</TD> ];
   }
 
   print qq|
   <TD ALIGN="CENTER" STYLE="font-family:serif; font-size:14px;background-color:#cc9900">
   <INPUT ID="prob_guilt$ev_count" NAME="prob_guilt$ev_count" SIZE="7" |;
 
   if ($me->{pass}!=1){
     print qq| VALUE="|.($prob_guilt?$prob_guilt:"").qq|" |;
   }
 
   print qq| MAXLENGTH="6">%</TD>
   <TD ALIGN="CENTER" STYLE="font-family:serif; font-size:14px;background-color:#cc9900">
     <INPUT TYPE="TEXT" ID="prob_innoc$ev_count" NAME="prob_innoc$ev_count" SIZE="7" |;
 
   if ($me->{pass}!=1) {
     print qq|VALUE="|.($prob_innoc?$prob_innoc:"").qq|"|;
   }
 
   print " MAXLENGTH=6>%</TD>\n";
}
 
 
 
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 
.

Reply via email to