Jump to content
Server Maintenance This Week. ×

Determine if a word contains uppercase characters after first character


This topic is 4980 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi all

I am new to the concept of recursion. I am trying to create a function that returns a boolean if a word contains an uppercase character after the first character.

This is what I have wrote so far for MidCaps (text)

If ( Length ( text ) > 1  ; MidCaps ( Exact ( Right ( text; Length (text) ); Upper (Right ( text; Length (text))))))

This ends up in an infinite loop.

Could anyone offer any advice on where to go here and any information on debugging custom functions?

How do I watch the text parameter to see what is happening?

Thanks in advance

Lee

Link to comment
Share on other sites

Good point on the debugging question.

As I did above, I use Let() statements and if I want to test a parameter I set the result var to whatever I'm trying to see. That doesn't work for recursion though.

I suppose you could set a $$var repetition to grab whatever recursion level you're at and check in the Data Viewer.

I've never actually done that...though I'm going to give it a shot the next time I run into a touch recursive CF.

And for the function above...the text field never reduces because Right(text; Length(text)) = text

Link to comment
Share on other sites

I suppose you could set a $$var repetition to grab whatever recursion level you're at and check in the Data Viewer.

I've never actually done that...though I'm going to give it a shot the next time I run into a touch recursive CF.

If you find a simple and repeatable ( standardised ) way, let us know.

Link to comment
Share on other sites

I suppose you could set a $$var repetition to grab whatever recursion level you're at and check in the Data Viewer.

To watch a CF like this [ Inverse ( text ) ]:)

Let(

result = Right ( text ; 1 );

Case(

not IsEmpty ( text ) ;

result & Inverse ( Left ( text ; Length ( text ) - 1 ) ) )

)

)

you'll need one $$var and one $var, something like:

Let([color:red][

$$debug = $debug ;

result = Right ( text ; 1 )

[color:red]];

Case(

not IsEmpty ( text ) ;

[color:red]Let ( $debug = $debug & If ( $debug ; ¶ ) &

[color:green]result

[color:red]& " " & RightWords ( $debug ; 1 ) + 1 ;

result & Inverse ( Left ( text ; Length ( text ) - 1 ) ) ) [color:red];

[color:red]Let( $debug = "" ; "" )

)

)

So that at the end you'll have all the iterations into $$debug

Link to comment
Share on other sites

To watch a CF like this [ Inverse ( text ) ]:)

Let(

result = Right ( text ; 1 );

Case(

not IsEmpty ( text ) ;

result & Inverse ( Left ( text ; Length ( text ) - 1 ) ) )

)

)

I was thinking more of:

Let([

result = Right ( text ; 1 );

$$inverse[Length(text)] = result];

Case(

not IsEmpty ( text ) ;

result & Inverse ( Left ( text ; Length ( text ) - 1 ) )

))

So in the end you'll have the iterations in separate repeating global variables.

Your solution could work, but it seems awfully complicated. Why not:

Let([

result = Right ( text ; 1 );

[color:red]$$inverse = $$inverse & ¶ & result];

Case(

not IsEmpty ( text ) ;

result & Inverse ( Left ( text ; Length ( text ) - 1 ) )

))

Edited by Guest
Link to comment
Share on other sites

This topic is 4980 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.