Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
C5 & The VAL() Function
Message
From
06/04/2000 21:58:43
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Title:
C5 & The VAL() Function
Miscellaneous
Thread ID:
00356619
Message ID:
00356619
Views:
36
Please forgive the funny capitalization,
I ran this throug beautify. Re-reading it
now though, the emphasis is pretty close ;-)

I'm posting this fragment to see if there's
something obscure that I'm missing about the
VAL() function.'

THIS CODE basically JUST makes sure that the
FIRST "word" OF an address IS a numeric VALUE
greater than zero. Everthing seems TO WORK
fine until you het the VAL() FUNCTION.

Are there known problem WITH the VAL() FUNCTION
AND certain VALUES e.g. NULL, "ABCD", "12E5"
that kind OF thing.

(I know, I know, Bob. My plan IS TO CALL support
Friday AFTER I put out a few more fires here :-)

here's the code:
LPARAMETERS  vcAddr
*** Performs a gross check on an input value
*** to see if it generally meets the criteria
*** for a valid address.
***     vcAddr - The value to be checked
*** Returns .T. or .F.

LOCAL llRetVal
LOCAL x
LOCAL lnWordEnd
LOCAL lcWord

*** An address is probably invalid if
*** it is empty (duh?) or it is all digits
*** (e.g "1234") or if it contains only
*** one word (e.g. "Main") or it has no
*** digits ( e.g. "Main St")
*** o If it containst the string PO BOX
*** 	then it is pro'ly valid.
*** o If it contains the strings RR and
***		BOX (i.e. RR 11 BOX 2) then it
***		is pro'ly valid

llRetVal = .F.

* Don't change the default value if:
*             - there aren't at least two words
*             - the address is all digitis
*            - the address doesn't follow
*                general format of street
*                number, street name
* Check to see if it's an address that gets
* special processing
*            - the address is less than
*            five characters

IF EMPTY( vcAddr)
   llRetVal = .F.
ELSE
   IF NOT ( " " $ ALLTRIM( vcAddr) )
      llRetVal = .F.
   ELSE
      IF LEN( ALLTRIM( vcAddr)) < 5
         llRetVal = .F.
      ELSE
         IF THIS.AllDigits( vcAddr)
            llRetVal = .F.
         ELSE
            llRetVal = .T.
         ENDIF
      ENDIF
   ENDIF
ENDIF

IF EMPTY( vcAddr)
   lcWord = ""
ELSE
   lnWordEnd = AT( " ", vcAddr)
   IF lnWordEnd = 0
      lnWordEnd = LEN( vcAddr)
   ENDIF
   lcWord = SUBSTR( vcAddr, 1, lnWordEnd)
ENDIF

* The above used to be a simple
* lcWord = WORDNUM( vcAddr, 1)
* but the above code seemed to work better
* for a while

IF VAL( lcWord) = 0
   ... snip
The PROGRAM blows up ON THIS LINE
intermittently. I can RUN the SAME
DATA multiple TIMES flawlessly OR
I can RUN it one TIME AND GET the
ERROR. I'm trying to determine
IIwhether it ever occurs on the first'
TIME the PROGRAM RUNS.

Looking AT a couple OF different CALL
Stack listings, the PROGRAM can actually
follow different paths TO GET here, but
WHEN I GET the C5 ERROR it IS ALWAYS ON
THIS LINE. numeric/non-numeric DATA
doesn't seem to make a difference (as
it should not)
Next
Reply
Map
View

Click here to load this message in the networking platform