NOTE: The decoders
mailing list is no longer active. The list archives are made available for historical reasons.
On 8 May 2000, Jason Burks wrote:
Robb,I have some code that can be used to decode the strings read out of the netcdf files in a slightly different manner than your example on the support archives. This method uses the pack command. Just thought I would send you the code: This example reads out the station name into @statName list which is decoded in the for loop and pushed into the @nameid list, an entry for each station. $length is the max length of the string. ######################################################################NetCDF::varget($ncid,$varidName,\@start,\@count,\@statName);for ($counter=0; $counter<$#statName; $counter=$counter+$length-1) {push @nameid, pack("C*",@statName[$counter..$counter+$length-1]); } ######################################################################
Jason, Yes, the pack code is a much cleaner solution. Never thought of using it until lately. Will keep the code on-hand for future reference. Thanks, Robb...
Thought you might be interested in this. This is an alternative to the code below: for( $i = 0; $i <= $#STNS; $i += 4 ) {for( $j = $i; $j < ( $i + $stn_name_len ); $j++ ) { $station .= chr( $STNS[ $j ] ) ; } print "Station = $station\n" ; undef( $station ) ; }Jason
============================================================================== Robb Kambic Unidata Program Center Software Engineer III Univ. Corp for Atmospheric Research rkambic@xxxxxxxxxxxxxxxx WWW: http://www.unidata.ucar.edu/ ==============================================================================
decoders
archives: