Jump to content

"error 401" in the midle of a script


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

Recommended Posts

Hi,

I’ve searched the Forum and found a similar problem (post #198062). I’ve tried the suggested solution, bus it’s not working with me…

My script runs like this:

Set error capture [on]

Enter find mode []

Set field [“mark”, ““open””]

Modify last find

Set field [“mark_dup”, ““dup””]

Go to field [select/perform, “popupmenu field”]

Halt script

Perform find [restore]

If [“Status(CourrentError) = 401”]

Show message [“bla bla bla”]

If [“Status(CourrentMessageChoice) = 1”]

Show all records

End If

End If

So, if the “perform find” results in “0”, I keep getting the message “No records match this request.”

Can someone show me what’s wrong?

Thanks

Teresa

Note: I’m Portuguese, so my English is not as good as I’d like, sorry!

Link to comment
Share on other sites

Try moving the [color:red]Set Error Capture (on) step to just before [color:blue]]If [“Status(CourrentError) = 401”] and see if that doesn't do it.

HTH

Lee

Link to comment
Share on other sites

Try moving the Set Error Capture (on) step to just before ]If [“Status(CourrentError) = 401”] and see if that doesn't do it.

That wouldn't help, as the Set Error Capture [ On ] needs to preceed the Perform Find[]. Anyway, I can't see how the script would get to the If[] with the Halt Script in the middle of the Find process.

Try removing the Halt Script, or changing it to a Pause Script[] and see if it works.

Link to comment
Share on other sites

Thanks Lee and Ender!

The tip is great, as the scripts goes like this:

Enter find mode []

Set field [“mark”, ““open””]

Modify last find

Set field [“mark_dup”, ““dup””]

Go to field [select/perform, “popupmenu field”]

Pause/resume script []

Set error capture [on]

Perform find [restore]

If [“Status(CourrentError) = 401”]

Show message [“bla bla bla”]

If [“Status(CourrentMessageChoice) = 1”]

Perform script [sub-scripts, “xxxxxx”]

End If

End If

It’s a little different, because I made it as I really want it – if there are no records to be shown, then open a new record (and this as to be performed in a very specific script), and works!

Still... it keeps showing the message as it didn’t find any, even if there are records to be shown.

Should I start with an If? (but if what??)

Link to comment
Share on other sites

I don't know if will fix it but I see two more problems. You can remove the Modify Last Find step, as you are already in Find Mode[], and you can uncheck the Restore option on the Perform Find [] step, as this would replace whatever criteria the user/script had entered in the previous steps.

Link to comment
Share on other sites

Hi again, Ender

In the end, it had worked as simple as this:

Enter find mode []

Set field [“mark”, ““open””]

Modify last find

Set field [“mark_dup”, ““dup””]

Go to field [select/perform, “popupmenu field”]

Pause/resume script []

Set error capture [on]

Perform find [restore]

View as [view as List]

I don’t know why the “list view” makes the difference (perhaps because of the "error capture on"), but it works as simple as I wanted.

Of course I wouldn't get there if it wasn't for you guys.

Thanks again.

Teresa

Link to comment
Share on other sites

I’m sorry, Ender, you’re right! I didn’t copy de final script… In the final one, I suppressed de “modify last find” and “restore” from perform find:

Enter find mode []

Set field [“mark”, ““open””]

Set field [“mark_dup”, ““dup””]

Go to field [select/perform, “popupmenu field”]

Pause/resume script []

Set error capture [on]

Perform find []

View as [view as List]

This is the way it works!

My mistake, thanks again.

Link to comment
Share on other sites

1) Use the Set Error Capture [off] step sparingly: run the script for as little time as possible with error capture diabled. Do this by explicitly turning error capture back on.

2) Put the error code into a global field or script variable so you can refer to it later in the script if needed. This has to be the very next step after the step being trapped.

Enter find mode []

Set field [“mark”, ““open””]

Modify last find

Set field [“mark_dup”, ““dup””]

Go to field [select/perform, “popupmenu field”]

Pause/resume script []

Set error capture [on]

Perform find [restore]

Set Variable [ $error ; Get( LastError ) ]

Set error capture [off]

If [ $error = 0 ]

# no error stuff

Else

# error occurred stuff

Beep

If [ $error = 401 ]

Show Message [ "No records match that request."]

Else

Show Message [ "An error occurred."]

End If

End If

Link to comment
Share on other sites

Thanks for the tip, Vaughan.

I thought I could leave the script as it is (since it works), but, as I understand from your response, you recommend that there should be a “set error capture off”. Is that it? It’s not safe to leave it like this? This script will be used very often…

In the mean time, I’ll try to make it as you suggest.

Just tell me if it is really necessary.

Thanks

Teresa

I just noticed that you suggest “set variable”… I’m working with FM 5, and I think it only exists in FM7… is there another way?

Also, it seams to work like this:

Enter find mode []

Set field [“mark”, ““open””]

Set field [“mark_dup”, ““dup””]

Go to field [select/perform, “popupmenu field”]

Pause/resume script []

Set error capture [on]

Perform find []

View as [view as List]

Set error capture [off]

Is it bad or can I leave it like this?

Edited by Guest
Link to comment
Share on other sites

This topic is 5654 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

  • Who Viewed the Topic

    1 member has viewed this topic:
    chalermchai 
×
×
  • Create New...

Important Information

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