Announcement

Collapse
No announcement yet.

Error code description without using an RC

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error code description without using an RC

    In QB there was a way to retrieve the error description
    71 = Disk not ready

    etc..
    Was this some call to dos?


    ------------------
    hellobasic

  • #2
    I would doubt it, since few runtime errors could be DOS errors. More than likely the runtime library provided the message.

    However, this is off topic for this forum... maybe you could try asking in the PB/DOS forum?

    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment


    • #3
      Not quite off topic, i was polling if this method still was available in Windows somewhere.
      Why adding error descriptions myself if they are somewhere in the Windows resources?

      Maybe for a future release of PB, the compiler might use windows errors (%ERROR_...) instead.
      Or by #option or sort off.

      The Open File for is using DOS error codes while internally the errors are %ERROR_ codes.



      ------------------
      hellobasic

      Comment


      • #4
        You mean Text descriptions for API errors?

        Code:
        DECLARE FUNCTION SystemErrorMessageText (BYVAL ECode AS LONG) AS STRING
        FUNCTION SystemErrorMessageText (BYVAL ECode AS LONG) AS STRING
          LOCAL Buffer AS ASCIIZ * 255
          FormatMessage %FORMAT_MESSAGE_FROM_SYSTEM, BYVAL %NULL, ECode, %NULL, buffer, SIZEOF(buffer), BYVAL %NULL
          FUNCTION = FORMAT$(ECode, "##### ") & Buffer
        END FUNCTION     
        
          X = SomeApiCallWhichReturnsFalseOnError
          IF ISFALSE (x) THEN
            E = GetLastError
            MSGBOX SystemErrorMessageText (E)
          END IF
        MCM

        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          I think:
          1) Maybe APIERR returns the real error, solves my problem then.
          2) A simple translation table can be useful (PB...?)


          ------------------
          hellobasic

          Comment


          • #6
            I think:
            PowerBASIC 'ERRAPI' = Win/32 'GetLastError'

            MCM
            Michael Mattias
            Tal Systems (retired)
            Port Washington WI USA
            [email protected]
            http://www.talsystems.com

            Comment


            • #7
              Edwin,

              Doesn't your earlier post of errlst do this with your function:-

              Code:
              Function GetErrorDescription( ByVal nError As Long ) As String
              
                  Dim sRtrnCode   As String
                  Dim lRet        As Long
              
                  sRtrnCode = String$( 2000, Chr$( 0 ) )
                  lRet = FormatMessage( %FORMAT_MESSAGE_FROM_SYSTEM, ByVal 0&, nError, 0&, ByVal StrPtr( sRtrnCode ), Len( sRtrnCode ), ByVal 0& )
                  If lRet > 0 Then Function = Left$( sRtrnCode, lRet )
              
              End Function
              David

              ------------------

              Comment


              • #8
                Sure but i wanted to use the DOS error list too.
                Errors 1 to ...99?
                This error list was available inside QB or using some DOS call, i don't know.

                Well, no longer available using the system but i think since we make use of 32bit programms, why is the pb compiler using old (translated from win32api) DOS errors?

                I still need to write an example to test if the errapi also returns the real 32bit error instead of the dos erro, while opening files etc..

                That's all and not a big problem.

                ------------------
                hellobasic

                Comment


                • #9
                  Edwin --

                  > why is the pb compiler using old (translated from
                  > win32api) DOS errors?

                  Those are BASIC error numbers, not DOS error numbers. Visual Basic uses exactly the same values, as do virtually all other BASIC languages.

                  -- Eric



                  ------------------
                  Perfect Sync Development Tools
                  Perfect Sync Web Site
                  Contact Us: mailto:[email protected][email protected]</A>
                  "Not my circus, not my monkeys."

                  Comment


                  • #10
                    Don't know if this helps or not..
                    Code:
                    Function AppError(ErrType As Long) Export As String
                    Dim Er(100) As String
                    Er(0)= "No Error
                    Er(5)= "Illegal Function Call
                    Er(7)= "Out of memory
                    Er(9)= "Subscript / Pointer Out of range
                    Er(51)= "Internal Error
                    Er(52)= "Bad file Name Or number
                    Er(53)= "File Not found
                    Er(54)= "Bad file mode
                    Er(55)= "File is already Open
                    Er(57)= "Device I/O Error
                    Er(58)= "File already exists
                    Er(61)= "Disk full
                    Er(62)= "Input past End
                    Er(63)= "Bad record number
                    Er(64)= "Bad file Name
                    Er(67)= "Too many files
                    Er(68)= "Device unavailable
                    Er(70)= "Permission denied
                    Er(71)= "Disk Not ready
                    Er(72)= "Disk media Error
                    Er(74)= "Rename across disks
                    Er(75)= "Path/File access Error
                    Er(76)= "Path/File Not found"
                    Er(76)=  "Error " + Trim$(Str$(ErrType))
                    If Er(Errtype) <> "" Then
                       Function = Er(ErrType)
                    Else
                       Function = "Unknown Error (" + Ltrim$(Str$(ErrType)) + ")"
                    End If
                    Erase Er
                    End Function

                    ------------------
                    Scott
                    Scott Turchin
                    MCSE, MCP+I
                    http://www.tngbbs.com
                    ----------------------
                    True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

                    Comment


                    • #11
                      That list is missing a couple of entries:

                      Er(24) = "Device Timeout"
                      Er(69) = "COMM error"

                      ------------------
                      Lance
                      PowerBASIC Support
                      mailto:[email protected][email protected]</A>
                      Lance
                      mailto:[email protected]

                      Comment


                      • #12
                        Eric,

                        I think you are right


                        ------------------
                        hellobasic

                        Comment


                        • #13
                          It's missing a whole lotta fields actually, I was testing for specific errors and never completed it since the GetLastErrorDescription Api was discovered hehe....




                          ------------------
                          Scott
                          Scott Turchin
                          MCSE, MCP+I
                          http://www.tngbbs.com
                          ----------------------
                          True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

                          Comment

                          Working...
                          X