Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

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

Recommended Posts

Posted

Want to make a little "quicksearch" field in a solution. (Still in Fmp10adv).

The script should check a global field and then proceed based on whether the field contains a number or text.

So I need some "if" logic. Simple enough. But my brain's cramping on how to identify whether the field contains text or a number.

Tried some IsValid combinations like IsValid(Abs(thefield)) but apparently the absolute value of some text is valid.... as is the Int of some text.

So I need a boolean result based on whether the field contains text or a number.

... or maybe a reliable way to generate a particular error whenever it's text or whenever it's a number. Would be easy enough to condition the script on the error.

Posted

whether the field contains a number or text.

That's hard to say, because if the field type is Text, and it contains only numeric characters - it's still text. What it the purpose here?

  • Like 1
Posted

The script should check a global field and then proceed based on whether the field contains a number or text

If there aren't fractions of 1 written with a leading zero ( like 0.23 ) or positive numbers written this way: +1.3 or numbers with thousand separators, you can try:

Length ( YourGlobalField ) = Length ( GetAsNumber ( YourGlobalField ) )

This returns 1 ( true ) for a number and 0 ( false ) for a text.

Posted

Why would the length be the same? (trick question...)

GetAsNumber ( YourGlobalField ) returns:

1) each number of the field ( excluding all leading zeros )

00aaaa0002 returns 2

2) the eventual first dot starting from left and ALL the other numbers ( including zeros ) that follow the dot

aaa000.aaa0.002 returns .0002

3) the eventual minus sign ( only if the leftmost char of the field )

-aaa000.aaa0002 returns -.0002

a-aa000.aaa0002 returns .0002

So, if we'll write a number respecting the above conventions, we'll have:

Length ( aNumber ) = Length ( aNumber )

P.S.: there can be problems when FileMaker starts to modify the number notation ( -10^9 or 10^9 )

Posted

So, if we'll write a number respecting the above conventions, we'll have:

Length ( aNumber ) = Length ( aNumber )

Wouldn't you also (or first) have:

aNumber = aNumber

?

Posted

That's hard to say, because if the field type is Text, and it contains only numeric characters - it's still text. What it the purpose here?

What I want the script to do is perform a search on field A if it's text but search on field B if its numeric. So, basically, trying to use one search field to perform multiple searches based on user behavior.

The app has an Amount field and also an Item Number field and a couple of text fields... so trying to search all of them from one box is probably a dream... it may be better to have one search box for text fields and one for the numeric fields or else buttons to route the script in one direction or the other.

Another option might be to just decide on a sequence and whenever the search comes back empty, try it again on the next field until there are hits... or a "nothing found" message.

... Unfortunately, the amount field could well contain something like .59 so that eliminates one of the other ideas above

Posted

The app has an Amount field and also an Item Number field and a couple of text fields... so trying to search all of them from one box is probably a dream...

Is it?

http://fmforums.com/forum/topic/65087-search-multiple-fields/page__p__308601#entry308601

Posted

i see, my bad

i can't believe there is no way of finding out if a value is a valid number without using a script or recursion

so what would be a valid number?

5

5.123

0.5

.5

0.0

1.0e+5

123,456

123,456.789

123 456

123 456.789

(same with minus sign)

am i missing any and is taking into consideration the formatting with "," and " " overkill?

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