Problems Creating UDF

Meeting place for R&R customers and clients to share tips and ideas. Post your questions, messages or problems here.
Post Reply
jmiskey
Posts: 46
Joined: Tue Oct 10, 2017 12:44 pm

Problems Creating UDF

Post by jmiskey » Mon Jul 25, 2005 2:15 pm

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.

kfleming
Posts: 5795
Joined: Tue Oct 10, 2017 12:44 pm

=> RE: Problems Creating UDF

Post by kfleming » Mon Jul 25, 2005 2:22 pm

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

jmiskey
Posts: 46
Joined: Tue Oct 10, 2017 12:44 pm

==> RE: Problems Creating UDF

Post by jmiskey » Mon Jul 25, 2005 3:12 pm

[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?____

kfleming
Posts: 5795
Joined: Tue Oct 10, 2017 12:44 pm

===> RE: Problems Creating UDF

Post by kfleming » Tue Jul 26, 2005 8:19 am

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

jmiskey
Posts: 46
Joined: Tue Oct 10, 2017 12:44 pm

====> RE: Problems Creating UDF

Post by jmiskey » Tue Jul 26, 2005 10:03 am

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?

kfleming
Posts: 5795
Joined: Tue Oct 10, 2017 12:44 pm

=====> RE: Problems Creating UDF

Post by kfleming » Tue Jul 26, 2005 4:26 pm

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

jmiskey
Posts: 46
Joined: Tue Oct 10, 2017 12:44 pm

======> RE: Problems Creating UDF

Post by jmiskey » Wed Jul 27, 2005 8:11 am

Interesting, and good to know.____One last question, what does the "$" do?____Thanks!

Post Reply