From: music@reg.triumf.ca (FRED W. BACH)
Subject: Re: Undocumented DCL feature
News-Software: VAX/VMS VNEWS 1.41    
Organization: TRIUMF: Tri-University Meson Facility
Date: Wed, 12 Aug 1992 20:12:00 GMT

In article <01GNG6OC1JD88WW6OR@ccmail.sunysb.edu>, Sanjay Kapur <skapur@ccmail.sunysb.edu> writes...
>>	F$LENGTH(100)	returns 3
>>
>>but, peversely enough...
>>
>>	F$LENGTH(100+" ") also returns 3
>>
>>therefore you can tell what class a symbol is by using ...
>>
>>	IF F$LENGTH(SYMB) .eq. F$LENGTH(SYMB+" ")
>>	THEN WRITE SYS$OUTPUT "SYMB is an INTEGER"
>>	ELSE WRITE SYS$OUTPUT "SYMB is a STRING"
>>	ENDIF
>>
>>wierd, huh? This has unexpected uses in formatting (knowing the number of
>>digits, that is) and in other stuff. If anyone finds a neater way of doing
>>this, please let me know.
>>
>>Nick
>>"DCL - the only real-time programming language for the '90s (1890s)"
>>
> 
> 
>What you are seing is (I believe) documented under DCL expression 
>evaluation in the DCL Concepts Manual.
> 
>When a numeric symbol and a nonnumeric string are concatenated using 
>a + sign, the result is a numeric.
> 
>Try the following commands:
> 
>$ WRITE SYS$OUTPUT 100+1
>101
>$ WRITE SYS$OUTPUT 100+"1"
>101
>$ WRITE SYS$OUTPUT 100+"a"
>100
>$ WRITE SYS$OUTPUT "100"+1
>101
>$ WRITE SYS$OUTPUT "100"+"1"
>1001
>$ WRITE SYS$OUTPUT "100"+"a"
>100a
> 
>Getting the above confused has cost me many hours of time debugging 
>DCL procedures that dod not work as expected.
> 
>  Sanjay Kapur    (SK54)              |Internet:    Sanjay.Kapur@sunysb.edu
>  Systems Staff, Computing Services,  |Bitnet:      SKAPUR@USB
>  State University of New York,       |SPAN/HEPnet: 44132::SKAPUR
>  Stony Brook, NY 11794-2400        |Phone:+1-516 632 8029, FAX:+1-516 632 8046
> 
> 
      In my early days of DCL programming I ran into the problem of having
to make sure that a symbol was indeed an integer.  Without using the
F$INTEGER lexical (which I didn't know about anyway), the following simple
method seemed to work every time:

        $ poo := 1991    !poo could be the answer to INQUIRE for the year

        $ poo = 'poo'

    This forced symbol poo to be an integer.  I suppose there is a way to
make it fail but it has worked for years in a plotting package I wrote
where the dates for extracting the data had to be acquired via DCL and the
DCL would have to produce a new command procedure with all the right input
lines for the .exe to digest.

   Here is a test command procedure to demonstrate the above:

   $delete/symbol/global poo
   %DCL-W-UNDSYM, undefined symbol - check validity and spelling
   $show symbol poo
   %DCL-W-UNDSYM, undefined symbol - check validity and spelling
   $poo :== 10
   $show symbol poo
     POO == "10"
   $poo == 'poo'
   $show symbol poo
     POO == 10   Hex = 0000000A  Octal = 00000000012
   $delete/symbol/global poo

    First the symbol POO does not exist.  Then we make it a string and
prove that it is a string.  Then we make it an integer and prove that
it is an integer with the show symbol command.  Works for me every time,
and it takes less typing than the f$integer lexical.  Anyone see any
major problems with this?

 Fred W. Bach ,    Operations Group        |  Internet: music@erich.triumf.ca
 TRIUMF (TRI-University Meson Facility)    |  Voice:  604-222-1047 loc 278/419
 4004 WESBROOK MALL, UBC CAMPUS            |  FAX:    604-222-1074
 University of British Columbia, Vancouver, B.C., CANADA   V6T 2A3

 These are my opinions, which should ONLY make you read, think, and question.
 They do NOT necessarily reflect the views of my employer or fellow workers.