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

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

Recommended Posts

Posted

Hi all

I Have a portion of a script that is not working and i cannot understand why.

Would someone look at it and tell me why.

Allow user Abotr [off]

Set Error Capture [On]

Set field [g_drawingno, ""]

Show Custom Dialog (Message) One button the "OK"

Dialog has an input Field (g-drawingno)

Go to layout [main]

Enter Find Mode

Insert Calculated Result[drawing_no,g_drawingno]

Performd Find

If[ Status(Currenterror)=401]

Beep

Show message (message) One button"OK"

Show all Records

go to layout (menu)

Exit Script

else

If (status(Currenterror)=400] "Find criteria is empty"

beep

Show mesage (mesage) One button"OK"

Go to Layout (Menu)

exit script

endif

endif

Perform Scrip

The status currenterror = 400 is being ignore by the script

Any ideas why

Thanks

Lionel

One more day closer to retirement

Version: v6.x

Platform: Windows XP

Posted

Maybe the current error is something other than 401 or 400, maybe 0 which means some records were found. Try saving and then displaying the value of the current error to see what value is actually being returned. This will help you trouble shoot the problem.

Posted

This sounds familiar, but I can't remember exactly why it works that way. One thing you can do is use If [ Status (CurrentFoundCount) = 0 ] as your check. Another option, especially if you have a lot of records in your db, is to make a relationship g_drawingno::drawing_no, and then Go to related, which is generally much faster than Find. You can also check up front whether there will be any found records, eg.:

If[ IsEmpty(g_drawRelationship::drawing_no) ]

.. Beep

.. etc.

Else

.. Go to related records(show, g_drawRelationship)

.. etc.

End If

Posted

The Set Error Capture [On] must go directly before the step you want to capture the error on. You can't just put it at the top, because it evaluates (behind the scenes) for every step.

Set Error Capture [On]

Perform Find []

Posted

It doesn't matter where the Set Error Capture [on] step is, as long as it's there.

The problem is that the second If is evaluating the error generated by the previous step -- in this case the Else. You need to create global number field (gError) and set the error from the Perform Find into it, then reference the gError field in the Ifs.

However your logic is still flawed: there can be errors generated other than 400 and 401 but your script lets these go untrapped.

Allow user Abotr [off]

Set field [g_drawingno, ""]

Show Custom Dialog (Message) One button the "OK"

Dialog has an input Field (g-drawingno)

Go to layout [main]

Enter Find Mode []

Insert Calculated Result[drawing_no,g_drawingno]

Set Error Capture [On]

Performd Find

Set Field [gError, Status(CurrentError)]

If[ gError=401]

Beep

Show message (message) One button"OK"

Show all Records

go to layout (menu)

Exit Script

else

If [gError=400] "Find criteria is empty"

beep

Show mesage (mesage) One button"OK"

Go to Layout (Menu)

exit script

Else

# Trap all other errors.

beep

Show mesage (mesage) One button"OK"

Go to Layout (Menu)

exit script

endif

endif

Perform Scrip

Posted

If you don't need to be specific, you can trap for any error like this:

Status (CurrentError) <> 0

In your particular case, Lionel, I don't see why you'd ever get a "Find criteria is empty" error, since your script does Insert Calculated Result[drawing_no,g_drawingno].

If it's possible for the g_drawingno to be empty, then you should probably trap for that before you even do the Find.

Posted

Hi Fitch

The input is done from a dialog pop-up and the operator has been known to press the "OK" button before enter information in the required field and then says the program is not working. So i thought i would send a message telling then that they did not enter any criteria in the required field.

Thanks

Lionel

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