Kris M Posted February 13, 2009 Posted February 13, 2009 I am looking for someone to coach me through building my first recursive CF. Scenario... Text field 1 record 1 contains "refste231" cf returns "refste" which is everything left of the first number in the string. Text field 1 record 2 contains "1q2w3e" cf returns null because left most char in the string is a number. Text field 1 record 3 contains "r324" cf returns "r" which is everything left of the first number in the string. Any thoughts on how to get this to work?
comment Posted February 13, 2009 Posted February 13, 2009 You don't really need a recursive calculation for this: Let ( [ num = Filter ( text ; "01234567889" ) ; firstNum = Left ( num ; 1 ) ; pos = Position ( text ; firstNum ; 1 ; 1 ) ] ; Case ( pos ; Left ( text ; pos - 1 ) ; text ) ) However, if you want to use this as an opportunity to learn about custom functions, then try an algorithm like: Check if the first character of text is numeric: if false, return the character, and check if text has more characters: if true, call the function again with the rest of the text.
Recommended Posts
This topic is 5760 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now