[ From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 17-SEP-1990 16:50:22.74  To:	MRGATE::"ARISIA::EVERHART" CC:	( Subj:	** Results of the DCL Challange **  * Received:  by crdgw1.ge.com (5.57/GE 1.73)) 	 id AA21373; Sun, 16 Sep 90 14:43:07 EDT / Message-Id:  <9009161843.AA21373@crdgw1.ge.com> ] Received: From SUN2.NSFNET-RELAY.AC.UK by CRVAX.SRI.COM with TCP; Sun, 16 SEP 90 11:37:07 PDT A Received: from vax.nsfnet-relay.ac.uk by sun2.nsfnet-relay.ac.uk  D           with SMTP inbound id aa04022; Sat, 15 Sep 90 2:42:14 +0000J Received: from sun.nsfnet-relay.ac.uk by vax.NSFnet-Relay.AC.UK via Janet 4           with NIFTP id aa12235; 14 Sep 90 17:15 BST Date: Fri, 14 Sep 90 17:56 BST, From: Nick de Smith <NICK@ncdlab.ulcc.ac.uk>9 To: INFO-VAX <@nsfnet-relay.ac.uk:INFO-VAX@crvax.sri.com> + Subject: ** Results of the DCL Challange **   B Here it is, what you have all been waiting for! The results of the   		 *Great DCL Challange*  I There have been many responses, most of which have worked. The winner was K decided by the most compact use of DCL. The second and third best solutions M were slightly less efficient variants of the winner. The fourth best solution M was a bit of a hack, but the winner of the "Most hideous and Over-Engineered" H solution has to be read to be believed! Congratulations to all those whoN supplied a correct solution (there were over 50!), and thanks to all those whoI took part. If there is interest, I'll organise another on the same lines.   : Again - * Congratulations * to all those who got it right!   nick	NICK@NCDLAB.ULCC.AC.UK      The winner was: 9 	*** Simon Graham	Digital Equipment Corporation (DEC) *** " equal first (but arrived later...)3 	* Sture Langemar	QZ Universitetsdata AB (Sweden) *   ( Second equal were (in order of arrival):2 	Matthew Madison		Rensselaer Polytechnic Institute4 	Guillaume Gerard	French Telecom University (France)  ' Third equal were (in order of arrival): 1 	Dave Greenwwod		(something with a gov.fed in it) % 	Jim Harvey		IUPIU Computing Services  	Wolfgang Moeller	GWDG (GDR) 	Peter Scott		NASA/JPL/Caltech 	Kevin Black		NERC (UK) : 	Michael Kimura		Hughes Aircraft Corp (at second attempt!) 				With help from Craig Lee  ( Fourth equal were (in order of arrival):( 	Harry Flowers		Memphis State University3 	Neill Clift		General Electric Corporation (GEC UK) 1 	R.R, Rodriguez		Southwest Texas State University   ? The winner of the "Most ghastly, nasty, and evil" solution was:   1 	*** Ed Klavins!!!!	Micrognosis (Switzerland)	***      The winning solution:    $! $!This is the "best" answer. $! $ Record[  0, 32 ] = %x0CA87960  $ Record[ 32, 32 ] = %x0094972C  $!U $ Write SYS$OUTPUT F$Fao( "Date : !%D", F$CvUI( 32, 32, F$Fao( "!AD", 8, Record ) ) )  $!( $! The previous statement works because:G $! 1.	"Record" is stored by DCL as a string, and is therefore passed by  $!	descriptor to functions. H $!	We use the "!AD" operator of $FAO to extract the descriptor of Record $!	using $!		F$Fao( "!AD", 8, Record ) 8 $!	which will return the descriptor as an 8 byte string. $! 2.	We now use, $!		F$CvUI( 32, 32, descriptor-as-a-string )R $!	to return the real address of the data as a 32 bit binary number in an integer.H $!	This extracts the second 32 bits of the "Record" descriptor, which isN $!	the value of the dsc$a_pointer element of the descriptor, ie the address of8 $!	the data element (the time quadword) that we require.Q $! 3.	Lastly, we use the address from step 2 as input to $FAO to get the date. As Q $!	the "!AD" format requires the address of a VMS time quadword, and integers are Q $!	passed by value to DCL lexical functions, this last $FAO returns the completed 
 $!	string. $!   The second best solution:  ------------------------i $ Write SYS$OUTPUT F$Fao( "Date : !%D", F$CvUI( 32, 32, F$Fao( "!AD", 8, %x'F$Fao( "!XL", Record )' ) ) )   2 This has one redundant term in the embedded "!XL".   The third best solution: ----------------------- l $ Write SYS$OUTPUT F$Fao( "Date : !%D", F$CvUI( 0, 32, F$Fao( "!AD", 8, %x'F$Fao( "!XL", Record )' ) + 4 ) )  g This has two redundant terms: the "!XL" (as in solution 2) and in the use of the "+ 4" term rather than  using the F$CvUI offset of 32.   A fourth solution: ----------------- d This is pretty tacky, but it works. You can write to any UW protected page of memory, but be warned:b DCL makes use of some of these pages, and writing to them can sometimes cause odd things to happen when using DCL.    $ Record[  0, 32 ] = %x0CA87960  $ Record[ 32, 32 ] = %x0094972C \ $ CTL$A_COMMON = %x7FFE0C00		! From SYS.MAP any user writeable page in P1 will do (arghhhh!)W $ Deposit /Long CTL$A_COMMON = F$CvUI( %x0*8, 32, Record ), F$CvUI( %x4*8, 32, Record ) 6 $ Write SYS$OUTPUT F$Fao( "Date : !%D", CTL$A_COMMON )   The *Most Awful* solution was: -----------------------------   : $ name	= f$parse( f$environment( "PROCEDURE" ),,, "NAME" )3 $ v=f$verify(0+f$integer(f$trnlnm(name+"_VERIFY")))  $ goto START $!+  $!K $!  A S C T I M . C O M  --  Convert binary time to ascii using DCL with NO  $!				image invocations  $! $!+ $! Author:	Ed Klavins, Micrognosis Zuerich.  $! $! Date:	11-SEP-1990 $!6 $! Environment:  VAX/VMS V5.3. No privileges required. $! $!, $!	P1  - first longword of VMS quadword time  $!	P2  - second longword of time $!J $! Setup:  This procedure scans the process symbol table, as stored in theM $!  process P1 space looking for the symbol containing the VMS quadword time. P $!  Once the symbol is found, then the address of the translation is calculated,> $!  and passed to the F$FAO lexical to be formatted as a date. $!O $!  There are two ways the symbol table could have been scanned: by reading the M $!  hash table sequentially and examining the symbol hashed at each entry, or L $!  by scanning the symbol definition blocks once they are linked in a list.I $!  The second method (which is easier, and quicker) is implemented here.  $!< $! NOTE: NO IMAGES ARE INVOKED IN DETERMINING THE ASCII TIME $!-  $START:  $ set symbol /scope=(NOLOCAL)  $! $ record[0,32]=f$integer(p1) $ record[32,32]=f$integer(p2)  $!H $! We do a SHOW SYMBOL here, which causes the known symbols to be linkedM $! in a linked list (since the symbols are not linked until they are required   $! to be listed alphabetically). $!   $ define sys$output nl: 
 $ sh symbol *  $ define sys$output sys$command  $!5 $ INFO	= "%" + NAME + "-I, "				! Information message 1 $ WARN	= "%" + NAME + "-W, "				! Warning message 6 $ FATAL	= "%" + NAME + "-F, "				! Fatal error message1 $ say	= "write SYS$OUTPUT"				! Print to terminal  $!@ $ CTL$AG_CLIDATA = %x7FFE2A5C	!should work for any VMS V5 system $! $! V5.3 CLI definitions -- $ PPD$Q_CLISYMTBL = %xC  $ POOL_OFFSET = %x1088 $! $ next_blkoff = %xC  $ symlen = %x23  $ symnam = %x24  $ symscpe = %x12 $  $ cnttotal = 0 $ cntlocal = 0 $ J $ clisymtbl = f$cvui(0,32,f$fao("!AD",4,CTL$AG_CLIDATA+PPD$Q_CLISYMTBL+4))' $ next_symblk = clisymtbl + POOL_OFFSET  $ 
 $SEARCH_LOOP:  $ symblk = next_symblk> $ next_symblk = f$cvui(0,32,f$fao("!AD",4,symblk+next_blkoff))+ $ if next_symblk .eq. 0 then goto NOT_FOUND  $ cnttotal = cnttotal + 1 4 $ local = f$cvsi(0,16,f$fao("!AD",2,symblk+symscpe))F $ if local .eq. -1 then goto SEARCH_LOOP	! Only check local symbols... $ cntlocal = cntlocal + 1 0 $ len = f$cvui(0,8,f$fao("!AD",1,symblk+symlen))> $! say INFO,"Local symbol is ",f$fao("!AD",len,symblk+symnam) H $ if f$fao("!AD",len,symblk+symnam) .nes. "RECORD" then goto SEARCH_LOOP* $! say INFO,"Local symbol RECORD found!!!"9 $ say INFO,"Date: '",f$fao("!%D",symblk+symnam+len+2),"'" ! $! addrtim == symblk+symnam+len+2  $ goto DONE  $! $NOT_FOUND: + $ say FATAL,"Local symbol RECORD not found"  $DONE:I $ say INFO,cntlocal,"/",cnttotal-cntlocal," LOCAL/GLOBAL symbols scanned"  $ exit 1+0*f$verify(v)    