Problems Creating UDF
Problems Creating UDF
I am trying to create a UDF that checks to see if a single character is numeric. I am doing this by comparing the ASC code value of this character and checking to see if it is between the 48 and 57 (the ASCII codes for the values 0-9).____Anyway, it is giving me an error un trying to save this formula. Can someone tell me what I am doing wrong? Here is is:____Declaration: IsNumeric(c_myEntry)__Expression: IIF((ASC(c_myEntry)>=48).AND.(ASC(c_myEntry)<=57),.T.,.F.)____I also tried reducing the expression to simply:__(ASC(c_myEntry)>=48).AND.(ASC(c_myEntry)<=57)__but that didn^t work either.
=> RE: Problems Creating UDF
Try the expression:____IIF((ASC(myEntry)>=48).AND.(ASC(myEntry)<=57),.T.,.F.)____The declaration includes the data type and the name where the expression uses only the name of the variable.____Kathleen__R&R Support
==> RE: Problems Creating UDF
[updated:LAST EDITED ON Jul-25-05 AT 03:14 PM (EST) by ()]Thanks. That did the trick.____I would like to use the UDF in a Recursive Function to check to see if all the entries are numeric (this is related to the following post you responded to: http://207.5.91.140/dcforum/DCForumID2/2757.html).____Basically, here is what I would like to do. Given some string, I would like to check that all the characters in spaces 3-7 are numeric, i.e.____GOOD__A_12345__B_02020__Z_54321_ABC____BAD__C_1234__D_12.345__E_12A35__F_1234_5____Unfortunately, I am quite lost in understanding the documentation on how to build a recursive function. Can you help me out?____
===> RE: Problems Creating UDF
You could do it without recursion by checking each character indivdidually. This expression checks if chars 3-7 are numeric digits.____SUBS(myentry,3,1)$"0123456789" AND __SUBS(myentry,4,1)$"0123456789" AND __SUBS(myentry,5,1)$"0123456789" AND __SUBS(myentry,6,1)$"0123456789" AND __SUBS(myentry,7,1)$"0123456789"____Kathleen__R&R Support
====> RE: Problems Creating UDF
Thanks! That works well!____Just one question though. I cannot find any documentation on this SUBS function. I can^t find it in the function list or in Help. ____Are there other function like this that may come in useful? Where can we find information on them?
=====> RE: Problems Creating UDF
R&R functions can be shortened to their first 4 characters so the SUBS in this expression is really the SUBSTR function that is in the documentation.____Kathleen__R&R Support
======> RE: Problems Creating UDF
Interesting, and good to know.____One last question, what does the "$" do?____Thanks!