Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

Determine if a word contains uppercase characters after first character


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

Recommended Posts

Posted

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

Posted

... or:

not IsEmpty ( Filter ( Right ( text ; Length ( text ) - 1 ) ; Upper ( text ) ) )

( if "text" contains only Alpha letters )

but I think that he asked for something else: how can you debug a CF ?

Posted

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

Posted

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.

Posted

There is a free tool for debugging custom functions, available from:

http://www.firstcontactsolutions.co.uk/CFExplorer.aspx

However, the solution is locked so I cannot tell how it works or if it works well.

In any case, the best way to debug IMHO is on paper.

Posted

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

Posted (edited)

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
Posted (edited)

Why do you need to?

______________________

I think a robust custom function debugging tool will require a EvaluationError(Evaluate(" function() ")) wrapper.

I tried downloading that tool that comment referred to but the download link wasn't working.

Edited by Guest
Posted

Why do you need to?

If nobody clears the $$var, the second debug will fail.

My way clears the $$var at the very beginning, when it set the $$var = $var ( that is initially empty )

Posted

I see. I assumed if you're debugging, you're going to start with a clean testing variable, clearing an earlier test either by script or from within the data viewer or by re-opening the file.

Your method takes care of that, but at a cost of complexity and clarity.

This topic is 5179 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.