Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

create a "File Not Found" error

Featured Replies

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

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.

  • Author

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.

  • Author

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???

Why would you use the Open URL instead of Send Event ?

  • Author

I'm open to suggestions.

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

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?

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

  • Author

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"

  • Author

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.

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)

  • Author

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.

  • Author

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

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...

  • Author

Yes. That is exactly what happened!

Thanks.

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.