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

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

Recommended Posts

Posted

How would I check a text field to see if the text in it is formated correctly? For example: I have a text field titled Index1. I have a script that puts text into that field. What I need to do is write another script that checks to see if the first letter is a "b" or "w" and the next character is a number. I now about the left function. But how do I test for a non-specific number?

Posted

Hi Heath, try script something like:

If [

[color:blue]Let (

[

alpha = PatternCount ( "bw" ; Left ( Index1 ; 1 ) ) ;

num = PatternCount ( "0123456789" ; Middle ( Index1 ; 2 ; 1 ) )

] ;

alpha and num

) ]

... passes test (do whatever)

Else

... fails test (do whatever)

End If

LaRetta :wink2:

Posted

I should explain ... I should have used Position() instead of PatternCount() because it is more [color:blue]efficient

Position() returns true (thus short-circuits) when the first pattern match is found; PatternCount() must continue through the entire text-string to count all pattern matches.

I used PatternCount() here because it would make the calculation look shorter : and I didn't think it would make much difference here. But in this business EVERY nanosecond counts and if one used the first calc in large text-string, the difference could be significant. So this calc is better than the prior (and I would use this one):

Let (

[

alpha = Position ( "bw" ; Left ( text ; 1 ) ; 1 ; 1 ) ;

num = Position ( "0123456789" ; Middle ( text ; 2 ; 1 ) ; 1 ; 1 )

] ;

alpha and num

)

But I would defect (to a different calc) in a heartbeat if it's better than this one, also!! :wink2:

LaRetta

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