Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Determine if a word contains uppercase characters after first character

Featured Replies

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

No need for recursion:

Let([

letters = Right(word; Length(word)-1);

caps = Filter(letters; "ABCDEFGHIJKLMNOPQRSTUVWXYZ");

result = not isEmpty(caps)

];

result

)

... 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 ?

How about:

Let (

t = Right ( text ; Length ( text ) - 1 )

;

not Exact ( t ; Lower ( t ) )

)

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

As always, you are unbeatable :)

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.

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.

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

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

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

Who clears the $$inverse ?

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

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 )

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.

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.