Jump to content

Stupid Script (or user?)


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

Recommended Posts

Hi all,

I've created a script which basically asks you to type in a filenumber. If the filenumber exists it goes to a layout, if it doesn't, it shows a message and puts you back at square one.

Problem - no matter which way I program it mad.gif, if the person clicks on OK without typing anything in at all it goes to the layout when it should throw up the message and back to square one.

So far i have as follows (have switched it around to be a positive response & a negative response to no avail).

Enter Find Mode

Show Custom Dialog ["File Number", "Insert the file number", "fileno"]

Set Error Capture [On]

Perform Find [Replace found set]

if ["Status(CurrentFoundCount) <= 0"]

Show Message ["No files exist with this matter number"]

Show All Records

Else

Go to Layout ["Display"]

End If

No matter if i make it a positive statement (i.e >= "1") And i've tried various other calcs, if at the "Show Custom Dialog" point, the user clicks on OK without having anything typed in (i.e blank), it will put them into the display layout. (i've tried doing an or and using "" as a result to no avail either)

Your help would be most appreciated! (and it will probably be somthing simple but i have a cold and i'm sooo over this tongue.gif)

Link to comment
Share on other sites

Hi kiwiora

I prefer to use globals when working with Custom Dialog. The following script should set you up. There are a few problems in your existing script so you might try this -

Create a field called gFileNumber (global, number). If your FileNumber is text, use a text field and drop the TextToNum portion from the following script. And the script would be:

Allow User Abort [ On ] turn off once the script is right

Set Error Capture [ On ]

Show Custom Dialog [ no title; Message: "Enter File Number"; Buttons: "OK",

"Cancel"; Input #1: select field gFileNumber, no label text ]

If [ Status(CurrentMessageChoice) = 2 ]

Halt Script

End If

If [ IsEmpty(gFileNumber) ]

Show Message [ Buttons: "OK", no cancel; Data: "You didn't enter a number. Try again." ]

Halt Script

End If

Enter Find Mode [ ] unclick all options

Set Field [ YourFileNumberField, TextToNum(gFileNumber) ]

Perform Find [ Replace Found Set ]

If [ not Status(CurrentFoundCount) ]

Show Message [ Buttons: "OK", no cancel; Data: "No Files exist with this Matter Number" ]

Show All Records

Halt Script

End If

Go to Layout [ Display ]

I hope that helps you forward. smile.gif

LaRetta

Link to comment
Share on other sites

Here is how I now handle custom dialogs now, to trap for invalid entries...

Allow User Abort [ Off ]

Loop

  Show Custom Dialog [ "Message", gFilenumber, OK, Cancel ]

  Exit Loop If [ IsEmpty(gFilenumber) = 0 or Status(CurrentMessageChoice) = 2 ]

  Beep

  Show Message [ "Please type a file number." ]

End Loop

If [ Status(CurrentMessageChoice) = 1 ]

  <rest of the process>

End If

The loop locks people into the dialog. They only get out by clicking Cancel (button 2) or making a valid entry into the field. Additional validation can be put into the Exit Loop step; for instance, I do a PatternCount on ValueListItems make the entry is from a pick list.

Link to comment
Share on other sites

Hi Vaughan,

PatternCount on ValueListItems make the entry is from a pick list.

This is an excellent way to Validate a field in Custom Dialog, thanks! And I like the loop too. I think it would be important to have Set Error Capture [On] here to suppress the standard dialog; otherwise, it interfers with the pretty way your script works. It's fun to use and very User-friendly. smile.gif

LaRetta

Link to comment
Share on other sites

Laretta wrote "I think it would be important to have Set Error Capture [On] here to suppress the standard dialog"

Not sure what you mean. I rarely use Set Error Capture [On] except just before Perform Find and a few other cases where I need to trap for errors.

Platform: / Version:

FileMaker Version:

Link to comment
Share on other sites

Vaughan said:

Laretta wrote "I think it would be important to have Set Error Capture [On] here to suppress the standard dialog"

Not sure what you mean. I rarely use Set Error Capture [On] except just before Perform Find and a few other cases where I need to trap for errors.

I believe this is in reference to the lines in HER script:

Perform Find [ Replace Found Set ]

If [ not Status(CurrentFoundCount) ]

To capture the error message as a result of this operation i guess? You have no such find in your script.

Platform: / Version:

FileMaker Version:

Link to comment
Share on other sites

Hi Vaughan! Hi Kenneth! smile.gif

I was referring to kiwiora's final script, incorporating the loop as Vaughan indicated - but which would still require a find (or as Vaughan indicated with <rest of process>). I had put together kiwiora's entire script to see how it would look, and in case he needed the final script. He indicated he still had to 'tweak it' - I thought he might need help incorporating the loop into his complete script. I've attached the sample I was working on.

Did I misunderstand how you were suggesting the loop be used, Vaughan? Or do I have something wrong in my script that I didn't account for (very possible). Isn't a find still necessary to give kiwiora what he needs? smile.gif

LaRetta

FileNumber.zip

Link to comment
Share on other sites

My apologies LaRetta, I was incorrect in thinking you were suggesting the Set Error Capture step was needed to make the Looped Custom Dialog work.

Indeed, your suggestions are beyond reproach. wink.gif

Link to comment
Share on other sites

This topic is 6559 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
 Share

×
×
  • Create New...

Important Information

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