From: Dave Greenwood [greenwoodde@ornl.gov] Sent: Wednesday, November 07, 2001 10:39 AM To: Info-VAX@Mvb.Saic.Com Subject: Re: Reading binary values in RMS Indexed Files via DCL In a previous article, del.duncan@intel.com (Del Duncan) wrote: > I'm trying to ready an RMS Index file and most of the fields are fine, > but there is one field that is a binary value which should be a > longword representation of a date; I'm having trouble reading it and > have been unsuccessful. I thought I could extract it from the line > and re-format it with f$fao but this hasn't worked either. Back in 1990 a challenge of sorts was held in this newsgroup for the best (most compact) use of DCL to convert a binary time to ascii using DCL. Here's the winning solution (from Simon Graham of DEC): $ Record[ 0, 32 ] = %x0CA87960 $ Record[ 32, 32 ] = %x0094972C $! $ Write SYS$OUTPUT F$Fao( "Date : !%D", - F$CvUI( 32, 32, F$Fao( "!AD", 8, Record ) ) ) The challenge was posed by Nick de Smith (NICK@ncdlab.ulcc.ac.uk) who posted this explanation: $! 1. "Record" is stored by DCL as a string, and is therefore passed by $! descriptor to functions. $! We use the "!AD" operator of $FAO to extract the descriptor of Record $! using $! F$Fao( "!AD", 8, Record ) $! which will return the descriptor as an 8 byte string. $! 2. We now use $! F$CvUI( 32, 32, descriptor-as-a-string ) $! to return the real address of the data as a 32 bit binary number in an integer. $! This extracts the second 32 bits of the "Record" descriptor, which is $! the value of the dsc$a_pointer element of the descriptor, ie the address of $! the data element (the time quadword) that we require. $! 3. Lastly, we use the address from step 2 as input to $FAO to get the date. As $! the "!AD" format requires the address of a VMS time quadword, and integers are $! passed by value to DCL lexical functions, this last $FAO returns the completed $! string. Dave -------------- Dave Greenwood Email: Greenwoodde@ORNL.GOV Oak Ridge National Lab %STD-W-DISCLAIMER, I only speak for myself