Gidday All,
 
A couple of you helped me with this before but I have misplaced my notes I am trying 
to pass an array to a subroutine and am having trouble.
 
As i am passing other variables as well I know I need to pass it by reference. Am I 
doing it correctly.
 
$pageContent = format_indexPage( \@picDetails,  0 );
 
 
sub format_indexPage{
  my ( $paramArrayPicDetails, $paramIndexPageId ) = @_;
  my $output = "";
 
  $output .= "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"5\" 
summary=\"\">";
  
  my $fromRow = $paramIndexPageId * 3;
  my $toRow = ($paramIndexPageId * 3) + 3;
  
  $numElements = scalar( @paramArrayPicDetails );
  iwpt_output("num elements array = $numElements<br>");  
  iwpt_output("from row $fromRow to row $toRow<br>");
    
  for( $rowPointer = $fromRow; $rowPointer < $toRow; $rowPointer++ ){
             
    my $dataCell0 = "&nbsp;";
    my $dataCell1 = "&nbsp;";
    my $dataCell2 = "&nbsp;";
    my $dataCell3 = "&nbsp;";
  
  if( defined( $paramArrayPicDetails[ $rowPointer * 4 + 0 ] ) ){
      $dataCell0 = format_cellData( $paramArrayPicDetails[ $rowPointer * 4 + 0 ] );
    }
    
    if( defined( $paramArrayPicDetails[ $rowPointer * 4 + 1 ] ) ){
      $dataCell1 = format_cellData( $paramArrayPicDetails[ $rowPointer * 4 + 1 ] );
    }
    
  if( defined( $paramArrayPicDetails[ $rowPointer * 4 + 2 ] ) ){
      $dataCell2 = format_cellData( $paramArrayPicDetails[ $rowPointer * 4 + 2 ] );
    }
    
    if( defined( $paramArrayPicDetails[ $rowPointer * 4 + 3 ] ) ){
      $dataCell3 = format_cellData( $paramArrayPicDetails[ $rowPointer * 4 + 3 ] );
    }
 
  $output .= "\t<tr>\n";
  $output .= "\t\t<td align=\"center\" valign=\"middle\">$dataCell0</td>\n";
  $output .= "\t\t<td width=\"1%\">&nbsp;</td>\n";
  $output .= "\t\t<td align=\"center\" valign=\"middle\">$dataCell1</td>\n";
  $output .= "\t\t<td width=\"1%\">&nbsp;</td>\n";
  $output .= "\t\t<td align=\"center\" valign=\"middle\">$dataCell2</td>\n";
  $output .= "\t\t<td width=\"1%\">&nbsp;</td>\n";
  $output .= "\t\t<td align=\"center\" valign=\"middle\">$dataCell3</td>\n";
  $output .= "\t<tr>\n";  
 }
 
 $output .= "</table>";
 
  return $output;
}
 
Any help appreciated
Thank You

Colin Johnstone 


 

Reply via email to