• Re: Error Number to Symbol

    From Lawrence D'Oliveiro@21:1/5 to Michael Brown on Tue Mar 18 05:58:10 2025
    On Tue, 18 Mar 2025 16:24:46 +1100, Michael Brown wrote:

    Working in C, how do you return the RMS$_CODE symbol for any given error number as returned from any operation?

    The $GETMSG system service comes to mind. I see there is a library routine LIB$SYS_GETMSG, not sure what that does that the system service call does
    not.

    There is also $PUTMSG, which is kind of like perror(3), but not quite.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Michael Brown@21:1/5 to All on Tue Mar 18 16:24:46 2025
    This might be a typical newbie question but I can't find any reference
    to it on the net.

    Working in C, how do you return the RMS$_CODE symbol for any given error
    number as returned from any operation? I use strerror() to get an interpretation but it does not include said symbol.

    exit(rms_return_number); will print it out so I know it must be possible.


    --
    House Harris Software.
    Making the world a safer place for our products. https://eisner.decus.org/~brown_mi

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Arne_Vajh=C3=B8j?=@21:1/5 to All on Tue Mar 18 10:01:58 2025
    On 3/18/2025 9:56 AM, Arne Vajhøj wrote:
    On 3/18/2025 1:58 AM, Lawrence D'Oliveiro wrote:
    On Tue, 18 Mar 2025 16:24:46 +1100, Michael Brown wrote:
    Working in C, how do you return the RMS$_CODE symbol for any given error >>> number as returned from any operation?

    The $GETMSG system service comes to mind. I see there is a library
    routine
    LIB$SYS_GETMSG, not sure what that does that the system service call does
    not.

    Classic LIB$ SYS$ difference in API style:

                                      SYS$                LIB$
    optional arguments         require placeholder   can be omitted readonly integer argument       by value          by reference string arguments            fixed length only      dynamic ok

    In C it is just different:

    #include <stdio.h>
    #include <stdint.h>

    #include <descrip.h>
    #include <lib$routines.h>
    #include <starlet.h>

    int main(int argc, char *argv[])
    {
    char msg[256];
    int32_t code, stat;
    int16_t msglen;
    $DESCRIPTOR(msgdesc, msg);
    code = 98962;
    stat = lib$sys_getmsg(&code, &msglen, &msgdesc);
    msg[msglen] = 0;
    printf("stat=%d msg=|%s|\n", stat, msg);
    stat = sys$getmsg(code, &msglen, &msgdesc, 0, 0);
    msg[msglen] = 0;
    printf("stat=%d msg=|%s|\n", stat, msg);
    return 0;
    }

    but in other languages the LIB$ variant can be convenient:

    $ bas/obj=msgfun sys$input
    program msgfun

    declare integer code, msglen, stat
    declare string msg
    external integer function lib$sys_getmsg(integer, integer, string)

    code = 98962
    stat = lib$sys_getmsg(code, msglen, msg)
    print stat
    print "|" + msg + "|"

    end program
    $
    $ link msgfun
    $ run msgfun
    1
    |%RMS-E-FNF, file not found|
    $ bas/obj=msgfun sys$input
    program msgfun

    declare integer code, msglen, stat
    map (fun) string msg = 256
    external integer function sys$getmsg(integer by value, integer, string,
    integer by value, integer by value)

    code = 98962
    stat = sys$getmsg(code, msglen, msg, 0, 0)
    print stat
    print "|" + mid$(msg, 1, msglen) + "|"

    end program
    $
    $ link msgfun
    $ run msgfun
    1
    |%RMS-E-FNF, file not found|
    $ bas/obj=msgfun sys$input
    program msgfun

    declare integer code, msglen, stat
    map (fun) string msg = 256
    external integer function sys$getmsg(integer by value, integer, string)

    code = 98962
    stat = sys$getmsg(code, msglen, msg)
    print stat
    !print "|" + mid$(msg, 1, msglen) + "|"

    end program
    $
    $ link msgfun
    $ run msgfun
    276
    $ bas/obj=msgfun sys$input
    program msgfun

    declare integer code, msglen, stat
    declare string msg
    external integer function sys$getmsg(integer by value, integer, string,
    integer by value, integer by value)

    code = 98962
    stat = sys$getmsg(code, msglen, msg, 0, 0)
    print stat
    !print "|" + mid$(msg, 1, msglen) + "|"

    end program
    $
    $ link msgfun
    $ run msgfun
    1537

    Arne

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Arne_Vajh=C3=B8j?=@21:1/5 to Lawrence D'Oliveiro on Tue Mar 18 09:56:50 2025
    On 3/18/2025 1:58 AM, Lawrence D'Oliveiro wrote:
    On Tue, 18 Mar 2025 16:24:46 +1100, Michael Brown wrote:
    Working in C, how do you return the RMS$_CODE symbol for any given error
    number as returned from any operation?

    The $GETMSG system service comes to mind. I see there is a library routine LIB$SYS_GETMSG, not sure what that does that the system service call does not.

    Classic LIB$ SYS$ difference in API style:

    SYS$ LIB$
    optional arguments require placeholder can be omitted
    readonly integer argument by value by reference
    string arguments fixed length only dynamic ok

    Arne

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Arne_Vajh=C3=B8j?=@21:1/5 to All on Tue Mar 18 10:07:10 2025
    On 3/18/2025 9:56 AM, Arne Vajhøj wrote:
    On 3/18/2025 1:58 AM, Lawrence D'Oliveiro wrote:
    On Tue, 18 Mar 2025 16:24:46 +1100, Michael Brown wrote:
    Working in C, how do you return the RMS$_CODE symbol for any given error >>> number as returned from any operation?

    The $GETMSG system service comes to mind. I see there is a library
    routine
    LIB$SYS_GETMSG, not sure what that does that the system service call does
    not.

    Classic LIB$ SYS$ difference in API style:

                                      SYS$                LIB$
    optional arguments         require placeholder   can be omitted readonly integer argument       by value          by reference string arguments            fixed length only      dynamic ok

    Dynamic string can be made to work with system service, but it
    it is a little cumbersome.

    Same Basic example:

    $ bas/obj=msgfun sys$input
    program msgfun

    declare integer code, msglen, stat
    declare string msg
    external integer function sys$getmsg(integer by value, integer, string,
    integer by value, integer by value)

    code = 98962
    msg = " "
    stat = sys$getmsg(code, msglen, msg, 0, 0)
    msg = mid$(msg, 1, msglen)
    print stat
    print "|" + mid$(msg, 1, msglen) + "|"

    end program
    $
    $ link msgfun
    $ run msgfun
    1
    |%RMS-E-FNF, file not found|

    Arne

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jim Duff@21:1/5 to Michael Brown on Wed Mar 19 06:21:29 2025
    On 18/3/25 16:24, Michael Brown wrote:

    This might be a typical newbie question but I can't find any reference
    to it on the net.

    Working in C, how do you return the RMS$_CODE symbol for any given error number as returned from any operation? I use strerror() to get an interpretation but it does not include said symbol.

    exit(rms_return_number); will print it out so I know it must be possible.



    https://www.eight-cubed.com/examples/framework.php?file=lib_sys_getmsg.c

    Cheers
    Jim
    --
    eight-cubed.com

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Michael Brown@21:1/5 to All on Thu Mar 20 02:34:04 2025
    This is gold!, thank you for this question fully answered. I can polish
    up my error handling routines now.




    On 19/3/25 01:01, Arne Vajhøj wrote:
    On 3/18/2025 9:56 AM, Arne Vajhøj wrote:
    On 3/18/2025 1:58 AM, Lawrence D'Oliveiro wrote:
    On Tue, 18 Mar 2025 16:24:46 +1100, Michael Brown wrote:
    Working in C, how do you return the RMS$_CODE symbol for any given
    error
    number as returned from any operation?

    The $GETMSG system service comes to mind. I see there is a library
    routine
    LIB$SYS_GETMSG, not sure what that does that the system service call
    does
    not.

    Classic LIB$ SYS$ difference in API style:

                                       SYS$                LIB$
    optional arguments         require placeholder   can be omitted
    readonly integer argument       by value          by reference
    string arguments            fixed length only      dynamic ok

    In C it is just different:

    #include <stdio.h>
    #include <stdint.h>

    #include <descrip.h>
    #include <lib$routines.h>
    #include <starlet.h>

    int main(int argc, char *argv[])
    {
        char msg[256];
        int32_t code, stat;
        int16_t msglen;
        $DESCRIPTOR(msgdesc, msg);
        code = 98962;
        stat = lib$sys_getmsg(&code, &msglen, &msgdesc);
        msg[msglen] = 0;
        printf("stat=%d msg=|%s|\n", stat, msg);
        stat = sys$getmsg(code, &msglen, &msgdesc, 0, 0);
        msg[msglen] = 0;
        printf("stat=%d msg=|%s|\n", stat, msg);
        return 0;
    }


    --
    House Harris Software.
    Making the world a safer place for our products. https://eisner.decus.org/~brown_mi

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)