Menu

Is there now a better way to access text returned by a C function?

2021-02-13
2021-02-13
  • Robert W.Mills

    Robert W.Mills - 2021-02-13

    I have recently upgraded from 3.0-rc1 to 3.1.2 and am wondering if there is now a better way to code the following:

    ::cobolfree
    
        01  c-text-pointer usage pointer.
        01  cobol-data     pic x(128) based.
        01  cobol-text     pic x(080).
    
        *> const char *c_function(void);
    
        call static "c_function" *> using nothing
                        returning c-text-pointer
        end-call
    
        set address of cobol-data to c-text-pointer
    
        string
              cobol-data delimited by low-values
              into cobol-text
        end-string
    
        set address of cobol-data to NULL
    
     

    Last edit: Simon Sobisch 2021-02-13
  • Simon Sobisch

    Simon Sobisch - 2021-02-13

    Totally: you look for function content-of:

    ::cobolfree
    
        01  c-text-pointer usage pointer.
        01  cobol-text     pic x(080).
    
        *> const char *c_function(void);
    
        call static "c_function" *> using nothing
                        returning c-text-pointer
        end-call
    
        move function content-of (c-text-pointer)
          to cobol-text
    
     

    Last edit: Simon Sobisch 2021-02-13
  • Robert W.Mills

    Robert W.Mills - 2021-02-13

    Thanks Simon

     

Anonymous
Anonymous

Add attachments
Cancel