home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.vms
- Path: sparky!uunet!ftpbox!mothost!schbbs!XMAC104@EMAIL.MOT.COM
- From: XMAC104@EMAIL.MOT.COM (Randy McGee)
- Subject: Re: Undocumented DCL feature
- Organization: Motorola Inc.
- Date: Wed, 12 Aug 1992 19:53:48 GMT
- Message-ID: <1992Aug12.195348.9997@schbbs.mot.com>
- References: <9208111504.AA19577@uu3.psi.com>
- Sender: news@schbbs.mot.com (Net News)
- Nntp-Posting-Host: 129.188.151.20
- Lines: 37
-
- In article <9208111504.AA19577@uu3.psi.com>, leichter@lrw.com (Jerry Leichter) writes:
- >
- > The only (neat) way I could find relies on
- > an undocumented feature of F$LENGTH - for a REAL integer (pun) it
- > always returns the number of digits in the integer. eg.
- >
- > F$LENGTH(100) returns 3
- >
- > but, peversely enough...
- >
- > F$LENGTH(100+" ") also returns 3
- ..
- > wierd, huh?
-
- This is caused by a somewhat misunderstood feature in DCL. The "+" operator has
- two functions: addition of integers and concatenation of strings. If the "+"
- operator is given mixed arguments, then the string argument is assumed to be a
- boolean and is converted to integer using the DCL boolean interpretation: any
- string beginning with a "Y", "y", "T", or "t" is interpreted as true, all others
- are interpreted as false. The integer boolean for true is 1 and 0 for false.
- Therefore, F$LENGTH(100+" ") ==> F$LENGTH(100+0) ==> F$LENGTH(100) ==> 3
-
- This also means that you can force a string to an integer for F$FAO arguments
- by simply adding zero to it:
-
- $ A = "100"
- $ SHOW SYMBOL A
- A = "100"
- $ B = F$FAO( "!UL", A )
- $ SHOW SYMBOL B
- B = "214740414"
- $ B = F$FAO( "!UL", A + 0 )
- $ SHOW SYMBOL B
- B = "100"
-
- MAGOO
-
-