Jump to content

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

Recommended Posts

Posted

I have defined a global field (as numeric).

I want to validate the input to that field (via custom dialog) results

in a numeric value or displays a dialog box.

I've tried:

NumToText(TextToNum(g_field)) <> g_field

-> It won't catch non-numeric values.

This is crazy

Any ideas?

Posted

Hi fmmike,

You can apply field validation to a global field. Change it to a standard numeric field, then select Options > Validation > Strict Data Type > Numeric. Then change it back to a global field. Click 'Strict, do not allow User override' and provide a message. Do you really want Custom Dialog to handle it?

Will your Users always be entering positive numbers? Would they ever enter -15 for instance? If not, I'm wondering ... do you really care what they enter in the field? If they accidently mis-type and enter garbage data along with their number, such as 67-4a when they meant to type 674, don't you want the result to be 674? You can just convert all numbers in the global to their strict numeric counterpart by using:

Set Field [substitute( Abs(NumericGlobal), ".", "" )]

The Abs() wil remove everything but numbers, including preceeding minus, pluses, spaces, alpha etc - all except the decimal. The Substitute() will remove the decimal. If you are going to use a script anyway, maybe you can save your Users from having to get the error message in the first place, and just fix it for them. In case they only enter garbage or text, this Set Field will remove it and leave the field empty. So, the next line in your script could be:

If [isEmpty(NumericGlobal)]

Custom Dialog or Show Message telling them to enter NUMBERS! crazy.gif

Just a few ideas! I used to use Set Field[] and set a field to itself - but it wouldn't remove the leading minus. Once I discovered Abs(), I love stripping them! I'm sure others will have better ones. smile.gif

LaRetta

Posted

LaRetta said:

Hi fmmike,

You can apply field validation to a global field. Change it to a standard numeric field, then select Options > Validation > Strict Data Type > Numeric. Then change it back to a global field. Click 'Strict, do not allow User override' and provide a message. Do you really want Custom Dialog to handle it?

That doesn't appear to work.

The custom dialog prompts for a user ID (numeric) or a Last name (alpha) in separate fields within the custom dialog. I evaluate which one is notEmpty and process from there. I just want to take the ID (gID) and ensure it is numeric.

From that point I do the Find.

Will your Users always be entering positive numbers? Would they ever enter -15 for instance? If not, I'm wondering ... do you really care what they enter in the field? If they accidently mis-type and enter garbage data along with their number, such as 67-4a when they meant to type 674, don't you want the result to be 674? You can just convert all numbers in the global to their strict numeric counterpart by using:

Set Field [substitute( Abs(NumericGlobal), ".", "" )]

This doesn't appear to work either.

That concept might work but I can't implement a working version.

The Abs() wil remove everything but numbers, including preceeding minus, pluses, spaces, alpha etc - all except the decimal. The Substitute() will remove the decimal. If you are going to use a script anyway, maybe you can save your Users from having to get the error message in the first place, and just fix it for them. In case they only enter garbage or text, this Set Field will remove it and leave the field empty. So, the next line in your script could be:

...snip ...

What are the errors of my ways?

Are your examples syntactically correct?

- fmMike

Posted

LaRetta,

My apologies for being brief. I shouldn't code and do "chores" concurrently.

What I am trying to do is:

- prompt the user via Custom Dialog box, (s)he has the option to enter either:

a known ID (numeric, indexed key)

or

enter the last name of the family (or a portion - from my previous topics/postings).

- If the ID is opted for entry I want to ensure it is a valid integer (this post).

- If it is blank I search via last name.

- else I drop out with a dialog "please enter some criteria"

Thus I have gleaned that validation will not fire within a Custom Dialog.

Since I don't expect that both values will be entered, the "join" option is unattractive.

 set field [substitute(Abs(g_Search_Family ID) , ".","")] 

Appears to work BUT

I need to include a test to trap for an input of all alphas.

Based upon my testing (ID = qwerty, It would fall through the code and give undesirable results.

Let me play with my new found knowledge.

But to quote my *new* governor "I'll Be Back!"

Is there an easy way to copy code snippets from FM scripts?

This is tedious...

- fmMike

Posted

Would work only if the input follows 0123 ....

Try this as you seem to check only that it doesn't start with a letter.

Position("0123456789abcdefghijklmnopqrstuvwxyz",Middle(yourGlobalNum,1,1),1, 1)>0

Posted

hi fmmike,

My oversight, sorry. I neglected to turn the right into a multikey. The relationship method is still the easiest way, I believe. You would just need to adjust your keys as follows. Left Key would just be just one field - the field in which the User enters either their ID or Last Name (called gID). You don't need separate fields for your User. Your right key would be: ID & "

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