4 Replies Latest reply: Jul 8, 2014 10:26 AM by Venelin Dimitrov RSS

    ErrorMode

      Dear All,

       

      I have a doubt here:

       

      If a set the error mode to 0 and then whant to create a msgbox if an certain script error happens how can i do it?

       

      Code:

       

      set errormode=0;

       

      Load * from xx;

       

      if ScriptError=8 then

      Load

      MsgBox('aa', 'aaa', 2, 48,512) as X

      AutoGenerate 1;

      //no file;

       

      Does anyone know if thats valid?

       

      Thanks,

      Eliano

        • Re: ErrorMode
          mayilvahanan ramasamy

          Hi

           

               What error ?

           

              

          set errormode=0;

           

          Load * from xx;

           

          if ScriptError=8 then

          Load

          MsgBox('Message 2', 'msgbox', 'OKCANCEL', 'ICONASTERISK') as x, 2 as r

          autogenerate 1;

          end if

           

          Details:

          1No error
          2General Error
          3Syntax Error
          4General ODBC Error
          5General OLE DB Error
          6General XML Error
          7General HTML Error
          8File Not Found
          9Database Not Found
          10Table Not Found
          11Field Not Found
          12File Has Wrong Format

           

          Hope it helps

          • Re: ErrorMode
            Rob Wunderlich

            I haven't syntax checked your example, but yes, the concept is valid.

             

            -Rob

            • Re: ErrorMode
              Fernando Suzuki

              Hi,

               

              you don't need a load statement to trigger the msgbox function. You can directly use it like this:

               

              set errormode=0;

              Load * from xx;

              if ScriptError=8 then

              let x = msgbox('file not found', 'caption');

              end if

               

               

              Another suggestion is to test if the file exists before loading it:

               

              if isnull(FileSize('c:\folder\x.txt')) then

                   let x = msgbox('file not found', 'caption');

              else

                   Load * from c:\folder\x.txt;

              end if

                • Re: ErrorMode

                  Hi,

                  I want to ask you, is it possible to create a msgbox in your script with text: 'the missing field':

                  I mean that:

                  SET ErrorMode = 0;

                  Load * from XX;

                  If ScriptError = 11 then

                  let x = msgbox ('Field not found' , 'Name of the missing field')

                  End If ;