Loading ...
Sorry, an error occurred while loading the content.

Macro question: branch when file not found?

Expand Messages
  • em315
    Another macro question that should be obvious but isn t obvious to me. I m writing a macro that opens a file on disk. I want to go to a label if the file does
    Message 1 of 2 , Mar 10, 2013
    • 0 Attachment
      Another macro question that should be obvious but isn't obvious to me.

      I'm writing a macro that opens a file on disk. I want to go to a label if the file does not exist. I In WP for DOS, this is handled by putting a line "On Error (labelname)" before the line that opens the file. That doesn't seem to work in WPMac, and the Macro Manual says that "On Error" is used to trap memory errors.

      How can a macro test whether a file exists?
    • John R
      I d thought this kind of error handler would do it (file biff doesn t exist): On Error (anError) Open Document ( Storyville:users:jrethorst:biff ) Alert ( I
      Message 2 of 2 , Mar 10, 2013
      • 0 Attachment
        I'd thought this kind of error handler would do it (file "biff" doesn't exist):

        On Error (anError)
        Open Document ("Storyville:users:jrethorst:biff")
        Alert ("I found the file")
        Return
        Label (anError)
        Alert ("I didn't find the file")

        but WP opens the last file opened, in whatever folder, and says it found the file.

        A longer script using the commands Set Directory and Get File could probably be made to work, but it would be convoluted. I've had more luck doing larger-scale operations with Applescript, and using WP's redoubtable 900 macro commands and objects for more specific actions.

        John R.



        --- In wordperfectmac@yahoogroups.com, "em315" <em315@...> wrote:
        >
        > Another macro question that should be obvious but isn't obvious to me.
        >
        > I'm writing a macro that opens a file on disk. I want to go to a label if the file does not exist. I In WP for DOS, this is handled by putting a line "On Error (labelname)" before the line that opens the file. That doesn't seem to work in WPMac, and the Macro Manual says that "On Error" is used to trap memory errors.
        >
        > How can a macro test whether a file exists?
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.