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

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

Recommended Posts

Posted

Is it possible to allow the user to abort a lengthy find, but have the containing script still continue?

I'd like to return the user to the proper layout and set the status area back if they cancelled the find.

Sample code that I thought would work:

Allow user abort [off]

Goto Find Layout

Hide Status bar

Enter Find Mode [Pause]

Allow user abort [On]

Perform Find

If[status(CurrentError) = 1]

Perform Script [Return_User_Somewhere]

End If

Perform Script [Display_Found_Results]

Obviously this is stripped down, but the concept is there, but apparently if the user cancels the find, the script dies right at the Perform Find step. Leaving them in an undesirable state.

Posted

I understand what you're trying to do, but your solution logic won't fit. You're on the right track by taking the user to a 'find' layout. What you do want to do is turn off user abort. The catch is that you must then trap and account for any errors. Here's what your script should look like:

Allow user abort [off]

Goto Find Layout

Hide Status bar

Enter Find Mode [Pause]

Perform Find

If[status(CurrentFoundCount) = 0]

Show Message [Your_message_here] with a Cancel and Try Again button

If Status(CurrentMessageChoice) = 1 {Cancel}

Perform Script [Return_User_Somewhere]

End If

If Status(CurrentMessageChoice) = 2 {Try Again}

Perform Script [Find_Script] {start all over}

End If

End If

Perform Script [Display_Found_Results]

Now, on your find layout place a 'Cancel' button that runs the 'Return_User_Somewhere' script and to Halt the current script.

You can also place a 'Find' button that would just resume script - that way the user can either hit enter to start the find or click the 'find' button after entering the find criteria.

Another option on a 'Find' layout is to use global find fields to get the user's find criteria, then use the Set Field script step to set up the find criteria. One advantage of this option is that you could provide one global 'find' field and then find any records that have that criteria in any field - like a keyword search. The other advantage is the user would be entering data in a field that is basically 'throw-away' data - less likelyhood that the user might enter data in the actual fields thinking they are in Find Mode when they are really in Browse Mode (Trust me - it does happen) and the actual data is changed in a record.

The down side is you have to use a find button to activate the second half of the script.

Here's what this scripts would look like:

Enter Browse Mode

Allow user abort [off]

Goto Find Layout

Hide Status bar

The 'Find' button script would be the other half of the script:

Enter Find Mode

Set Field ["Field1","_gFindField1"]

Set Field ["Field2","_gFindField2"]

Set Field ["Field3","_gFindField3"] {etc.}

{or for a key word search:

Set Field ["Field1","_gFindField"]

New Request

Set Field ["Field2","_gFindField"]

New Request

Set Field ["Field2","_gFindField"] etc.}

Perform Find

If[status(CurrentFoundCount) = 0]

Show Message [Your_message_here] with a 'Cancel' and 'Try Again' button

If Status(CurrentMessageChoice) = 1 {Cancel}

Perform Script [Return_User_Somewhere]

End If

If Status(CurrentMessageChoice) = 2 {Try Again}

Perform Script [Find_Script] {start all over}

End If

End If

Perform Script [Display_Found_Results]

Posted

Hi dykstrl,

I appreciate the length and detail of your response, however, I think the real objective that I'm after isn't solved my your solution.

My main problem is between these two steps.

Perform Find

If[status(CurrentFoundCount) = 0]

I was asking if it's possible to allow them to cancel the find. The actual find, meaning, when the find progress bar is up and running. We have many, many (300,000+) records and it's possible (depending on the complexity of their find), that it can take minutes (many minutes or more) to complete the find (and therefore continue on to the next step you recommended)

But when Allow User Abort is set to OFF, the cancel button is gone from the Find progress bar. This FORCES them to wait, or worse, Force Quit/End Task the application.

But what I found is that with Allow User Abort is ON, then clicking the cancel button on the Find dialog actually kills the script too.

My temporary solution so far has been to Allow user abort ON right before they Perform Find, but just before the find executes, freeze the screen and switch the layout to a "safe" drop layout. That way if the DO cancel, by the time the screen refreshs, they are already back to where they started from. The only bugger about that is the darn status area. Even with a freeze window script step, it draws back on the screen as a large white box. (Which pushes the find layout over). I'm stuck with the darn status area not by my choice, otherwise it would be perfect.

Any other thoughts? Or should I do what you recommended and find out that it does what I'm asking?

Posted

I think you're asking why dykstrl's solution won't solve my problem.

If that's what you're asking, I would respond, "Because I want to be able to cancel the actual find while it's taking place. Not just cancel a script after the find completes. You can't click a "Cancel" button that is sitting on a layout while the find dialog box is in progress"

Posted

That was actually your original questions :

Is it possible to allow the user to abort a lengthy find, but have the containing script still continue?

It is not clear in your post if the result of the script you want to perform could change depending on the previous find step. If the only step you want is Perform Script [Return_User_Somewhere], then I still think the first answer could be a good one.

Posted

Hi trevorg,

One issue is that with the Allow User Abort [Off] step in place, users would be unable to cancel the find. Whilst that is a flaw in the logic of the script you've outlined, fixing it will not solve your problem, I'm afraid.

Whilst what you are trying to do appears reasonable, unfortunately, cancelling a find automatically issues a Halt command which takes all scripts (not just the current one but any paused scripts also) out of the queue. This has been the case in all versions of FileMaker since I started using it over ten years ago.

Consequently, you cannot directly control subsequent events via script. However a work-around of sorts is to have the script set up the "return user here if the find is cancelled" location before issuing the Perform Find [ ] step, so that if the user cancels the find they end up there, but if they don't, the script goes on to complete the find then take the user to an appropriate layout to view the results.

The chief limitation of this work-around is that as well as halting all scripts, cancelling the find will issue a 'Show All Records' command. Thus the user will be browsing the whole file after cancelling the find. If this is a problem, you can ameliorate it by providing a button with which the user can restore an appropriate found set - but I'm not aware of a perfect solution unless you have access to a plug-in such as Activator, SCRIPTit or Events (which can be used to script a 'safety net' behind the find script).

Sorry that the news is not better...

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