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

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

Recommended Posts

Posted

I can't seem to figure this out (and i'm sure it's some easy solve).

I have a button that opens a file. But I want an error to popup if the File is not FOund. I tried using the Get(LastError) but I think I might be doing it wrong. Can someone let me know what to do and how to script this? Thanks in advance

Posted

Hey Scott,

You need to add this step

Set Error Capture[On]

to your script before you attempt to open the document. That will suppress the regular warning messages and then you can test for errors using the Get(LastError). If Get(LastError) <> 0 then there was a problem and you could display a custom dialog box or do something else altogether.

Posted

My script goes like this:

Set Error Capture[on]

Open URL [no dialog; Filepath]

If [get (last Error) <> 0]

Show Custom Dialog [ "error"; "file not found"

else

Show Custom Dialog [ "File Opened"; "Passing!"

end if

I tried the suggestion on a Filepath that is incorrect and it keeps giving me "File Opened".

So I'm still not sure what it is doing.

Posted

Hmm. Interestingly enough. when I do this:

Open URL [no dialog; filepath]

ShowCustom Dialog ["Last Error" & Get(LastError)

it works.

but when I do

Open URL [no dialog; filepath]

If (Get(LastError) <> 0) then

Show Custom Dialog ["Last Error" & Get(LastError)

else

Show Custom Dialog ["File Opened")

it does NOT work.

Is there something with the IF statement???

Posted

I'm open to suggestions.

How do you use the Send Event? I have never used Send Event.

Posted

when I do this:

Open URL [no dialog; filepath]

ShowCustom Dialog ["Last Error" & Get(LastError)

it works.

What do you mean by it works? What code does it show?

Posted

Send Event is very simple. To open MS Word for instance you simply "send" this calculation:

"Winword.exe"

I'm curious as to why you have the ELSE line in your script. Try deleting it AND the custom dialog that follows it and you *may* have the answer to your problem.

FYI: ELSE is not mandatory when you use IF / END IF

Posted

Hmm. Interestingly enough. when I do this:

Open URL [no dialog; filepath]

ShowCustom Dialog ["Last Error" & Get(LastError)

it works.

but when I do

Open URL [no dialog; filepath]

If (Get(LastError) <> 0) then

Show Custom Dialog ["Last Error" & Get(LastError)

else

Show Custom Dialog ["File Opened")

it does NOT work.

Is there something with the IF statement???

Let me Clearify. When I use the first code (without error statement) it returns an error code "5".

When the If Statement checks the Get(lastError), it always shows error code "0"

Posted

Send Event is very simple. To open MS Word for instance you simply "send" this calculation:

"Winword.exe"

I'm curious as to why you have the ELSE line in your script. Try deleting it AND the custom dialog that follows it and you *may* have the answer to your problem.

FYI: ELSE is not mandatory when you use IF / END IF

If I just do a Send Event "Winword.exe" all it does is open MS Word. it does not open the file I need opened.

Currently the ELSE statement is used for debugging the script. To show a dialog box to show something was processed.

Posted

Hello Scott,

Try to work with "Script Debugger." It would show step by step of your script. Anyway, what is filepath? Is it a variable name or something else?

Error Code 5 means : Command is invalid (for example, a Set Field script step does not have a calculation specified)

Posted

OK I got it. Here's my Code:

Set Error Capture[on]

Open URL [No Dialog; Filepath]

Set Variable[$errorNumber; Value:Get(LastError)]

If[$errorNumber <> 0 ]

_ Show Custom Dialog ["Error"; File Not Found. LastError: " & $ErrorNumber]

End If

So...

It looks like the "IF" test does a "get(LastError)" it clears the error code. then when the statement does a "Get(LastError)" the original error is gone. And that threw off my debugging dialog box.

I used a variable to store the Get(LastError). and ran the IF Test off of it.

And now that it works, I removed the "Else" and statements.

Thanks to: fabriceN and _henry_ and Ted S for their suggestions in helping me debug this problem.

Posted

Hello Scott,

Try to work with "Script Debugger." It would show step by step of your script. Anyway, what is filepath? Is it a variable name or something else?

"Dear Santa, For Christmas I'd like Filemaker Pro Advanced."

: I don't have Filemaker Pro Advanced. But I should really look into it.

Thanks

Posted

It looks like the "IF" test does a "get(LastError)" it clears the error code.

Well, as far as I know, the "Last Error" code that generated would be useful if you use it in directly using Get (LastError) in the next line (whether you saved it in the variable or using IF). However, if you do not save it directly, it would be gone. For example:

Open URL (No Dialog; filepath)

Set Variable ($Counter; Value: 1)

Set Variable ($ErrorCode; Value: Get(LastError))

The $ErrorCode would not get the error code that throw by the Open URL...

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