home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / os / vms / 13587 < prev    next >
Encoding:
Text File  |  1992-08-12  |  1.6 KB  |  50 lines

  1. Newsgroups: comp.os.vms
  2. Path: sparky!uunet!ftpbox!mothost!schbbs!XMAC104@EMAIL.MOT.COM
  3. From: XMAC104@EMAIL.MOT.COM (Randy McGee)
  4. Subject: Re: Undocumented DCL feature
  5. Organization: Motorola Inc.
  6. Date: Wed, 12 Aug 1992 19:53:48 GMT
  7. Message-ID: <1992Aug12.195348.9997@schbbs.mot.com>
  8. References: <9208111504.AA19577@uu3.psi.com>
  9. Sender: news@schbbs.mot.com (Net News)
  10. Nntp-Posting-Host: 129.188.151.20
  11. Lines: 37
  12.  
  13. In article <9208111504.AA19577@uu3.psi.com>, leichter@lrw.com (Jerry Leichter) writes:
  14. >                                 The only (neat) way I could find relies on
  15. >     an undocumented feature of F$LENGTH - for a REAL integer (pun) it
  16. >     always returns the number of digits in the integer. eg.
  17. >         F$LENGTH(100)    returns 3
  18. >     but, peversely enough...
  19. >         F$LENGTH(100+" ") also returns 3
  20. ..
  21. >     wierd, huh?
  22.  
  23. This is caused by a somewhat misunderstood feature in DCL. The "+" operator has
  24. two functions: addition of integers and concatenation of strings. If the "+"
  25. operator is given mixed arguments, then the string argument is assumed to be a
  26. boolean and is converted to integer using the DCL boolean interpretation: any
  27. string beginning with a "Y", "y", "T", or "t" is interpreted as true, all others
  28. are interpreted as false. The integer boolean for true is 1 and 0 for false.
  29. Therefore, F$LENGTH(100+" ") ==> F$LENGTH(100+0) ==> F$LENGTH(100) ==> 3
  30.  
  31. This also means that you can force a string to an integer for F$FAO arguments
  32. by simply adding zero to it:
  33.  
  34.    $ A = "100"
  35.    $ SHOW SYMBOL A
  36.      A = "100"
  37.    $ B = F$FAO( "!UL", A )
  38.    $ SHOW SYMBOL B
  39.      B = "214740414"
  40.    $ B = F$FAO( "!UL", A + 0 )
  41.    $ SHOW SYMBOL B
  42.      B = "100"
  43.  
  44. MAGOO
  45.  
  46.