Highlighted
Valued Contributor.
Valued Contributor.
2673 views

GETTING FEED BACK FROM NON COBOL CALLED PROGRAM

Jump to solution

hello,,

I'm using the bellow routine it's working fine,

move spaces to RU-Command-Line.
string "vuescan.exe" delimited by size
into RU-Command-Line
end-string.

move length of RU-Command-Line to RU-Command-Line-Len.
move 0 to RU-Stack-Size.
move 0 to RU-Flags.

call "CBL_EXEC_RUN_UNIT"
using by reference RU-Command-Line
by value RU-Command-Line-Len
by reference RU-ID
by value RU-Stack-Size
by value RU-Flags
returning RU-Status-Code
end-call.
*
My qustion and needs :how can I get data from the called program "vuescan.exe", like the file-name and the path were that file have been saved,, and pass it to the calling program.

Regards

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Contributor
Micro Focus Contributor

Hi Shatty,

First off I notice you are executing "vuescan.exe" asynchronously so the program can never pass anything back to the program that initiates it. You notice that I say initiates rather than call as "CBL_EXEC_RUN_UNIT" executes "vuescan.exe" in another operating system process not in the same process as the program that invokes it. If you look up the documentation for "CBL_EXEC_RUN_UNIT" you will notice RU-Flags should contain 1, not zero to execute synchronously.

Given the fact that you are invoking a program in another run unit you have only two choices to get those sort of details:

  1. Pipe the screen output of "vuescan.exe" to a file and read the file by moving ""vuescan.exe > filename.txt" to the command line (not sure why you are using string rather than move.
  2. Alter "vuescan.exe" so that it writes the information you require to an environment variable and read the environment variable in the invoking program.

Good luck,

Michael

View solution in original post

0 Likes
10 Replies
Highlighted
Micro Focus Contributor
Micro Focus Contributor

Hi Shatty,

First off I notice you are executing "vuescan.exe" asynchronously so the program can never pass anything back to the program that initiates it. You notice that I say initiates rather than call as "CBL_EXEC_RUN_UNIT" executes "vuescan.exe" in another operating system process not in the same process as the program that invokes it. If you look up the documentation for "CBL_EXEC_RUN_UNIT" you will notice RU-Flags should contain 1, not zero to execute synchronously.

Given the fact that you are invoking a program in another run unit you have only two choices to get those sort of details:

  1. Pipe the screen output of "vuescan.exe" to a file and read the file by moving ""vuescan.exe > filename.txt" to the command line (not sure why you are using string rather than move.
  2. Alter "vuescan.exe" so that it writes the information you require to an environment variable and read the environment variable in the invoking program.

Good luck,

Michael

View solution in original post

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Actually, there is one more way that you can communicate data between different rununits and that is by using shared memory and the NX library routines, CBL_PUT_SHMEM_PTR and CBL_GET_SHMEM_PTR.

You can find an example in the knowledgebase article here:

0 Likes
Highlighted
Valued Contributor.
Valued Contributor.

Thanks Michael,, you're right, I will to make a test

0 Likes
Highlighted
Micro Focus Contributor
Micro Focus Contributor

Hi Chris,

Probably not a goer in this case though Chris as Shatty is communicating with a non-COBOL program ...

I'll admit to a bias against using shared memory for interprocess communication - there's just too many things that can go wrong, especially with locking. That's probably unfair of me but explains why I blocked it out!

Michael

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Hi Michael,

Sorry, I completely missed the part about it being a non-COBOL process even though it is right there in the post title.

Thanks

0 Likes
Highlighted
Valued Contributor.
Valued Contributor.

Hi Michael,

Thanks for your feedback, I understand the problem I’m facing as you did explain it, but I really get lost how to solve it out as you mentioned in that two choices,

I will appreciate it if you could give an example in how to do it.

Within the application I’m designing “using MF Netexpress 5.1”,, I need to scan documents and pictures as a part of an employee record,, then when that employee data to be retrieved these documents and pictures will be shown if required.

I don’t know how to use scanner in COBOL, that’s why I tried to "vuescan.exe"

Best regards

Shatty

0 Likes
Highlighted
Absent Member.
Absent Member.

Hi Shatty,

we have a quite similar need, and solved it very easy. Our Netexpress does not scan directly (that is done Independent with a Kodak ScanMate i1120  scanner and the included Software) We scan the documents that shall be linked into a certain specific folder.  (images to be linked) that should be possible with any scanner.

The NETEXPRESS program now makes the important job in the following steps:

1. with   call 'CBL_DIR_SCAN_READ'  it builds a table of all images to be processed   (all *.jpg in order to have small files).

2. A call to PDFCREATOR    or   PDFC1    converts all images  to  PDF  (to Show them with AcroRd)

3. A call to 'AcroRd32 /a "zoom=60" '  visualizes one image after an other on the screen.

4. The operator identifies the image, types the new name for the document.

5. Netexpress renames the file (=moves it to another folder), writes the name in a file which makes the link between the image and the invoice.

Perhaps you need some different steps for your purpose, but with this operation I avoide to scan the documents from within the Netexpress program, shared Memory, etc..

If you need more explanation, please tell me.

Rolf

0 Likes
Highlighted
Valued Contributor.
Valued Contributor.

Hi Rolf

Thanks for your interest and feedback,,  I really don't have good experience in Library routines, thus I can’t follow up how to use “CBL_DIR_SCAN_READ” .

Kindly if you send me a sample program of how using it I  will appreciate your help

My email :shatty1954@gmail.com

best regards

Shatty

0 Likes
Highlighted
Absent Member.
Absent Member.

Here the just compiled program, a DEMO from MICRO FOCUS.

000001$SET FOLDCOPYNAME"LOWER"

000002*

000004*

000009 identification division.

000010 program-id. dirdemo.

000011 data division.

000012 working-storage section.

000013

000014* Variables for CBL_DIR_SCAN_BEGIN

000015* Some used by other CBL_DIR_SCAN_ routines.

000016

000017* The handle.

000018 01 dir-handle     pointer.

000019

000020* The pattern.  I chose a null terminator instead of

000021* specified length.

000022 01 dir-name-pattern.

000023*    10 dir-name-pattern-length     cblt-x2-comp5 value zero.

000024     10 dir-name-pattern-length  pic xx comp-5 value zero.

000025     10 dir-name-pattern-text       pic x(2048).

000026

000027* The terminator.

000028 01 pattern-terminator         pic x value low-values.

000029

000030* Search attributes.

000031 01 search-attributes     pic x(4) comp-5 value zero.

000032     78 find-file         value 1.

000033     78 find-directory    value 2.

000034     78 find-neither      value 4.

000035

000036* Flags

000037 01 dirflags             PIC X(4) COMP-5.

000038     78 escape-seq       value 1.

000039     78 wildcards        value 2.

000040

000041 01 search-status        pic xx   comp-5.

000042

000043* Variables for CBL_DIR_SCAN_READ

000044

000045* The entry.

000046 01 entry-data.

000047     10 entry-data-attribute PIC X(4) COMP-5.

000048     10 entry-data-date-stamp.

000049         20 stamp-year   PIC X(4) COMP-5.

000050         20 stamp-month  PIC X(2) COMP-5.

000051         20 stamp-day    PIC X(2) COMP-5.

000052         20 stamp-hour   PIC X(2) COMP-5.

000053         20 stamp-minute PIC X(2) COMP-5.

000054         20 stamp-sec    PIC X(2) COMP-5.

000055         20 stamp-msec   PIC X(2) COMP-5.

000056         20 stamp-dst    PIC X    COMP-5.

000057         20 stamp-size   PIC X(8) COMP-5.

000058     10 entry-data-name.

000059         20 name-length  PIC X(2) COMP-5 value 50.

000060         20 name-text    pic x(50).

000061

000062* Variables for CBL_DIR_SCAN_END

000063* No additional data items required.

000064

000065* Command line argument data area

000066*01 arg-pos              pic 9 value 1.

000067*01 arg-text             pic x(2048) value spaces.

000068

000069* OTHER VARIABLES

000070 01 attrib-work          pic x    comp-5.

000071 01 attrib-text          pic x(10).

000072 01 nonblank-len         pic 9(9).

000073 01 terminator-position  pic 9(9).

000074 01 Indix                pic 99 usage comp.

000075 procedure division.

000076

000077* Check for directory specification on command line.

000078*    display arg-pos upon argument-number.

000079*    accept arg-text from argument-value.

000080*    if arg-text = spaces

000081         move '\cobol\source\cli*.cbl' to dir-name-pattern-text

000082*        move '\cobol' to dir-name-pattern-text

000083*            else

000084*        move arg-text to dir-name-pattern-text.

000085

000086* Find the nonblank length and append string terminator.

000087     perform varying nonblank-len

000088         from function length(dir-name-pattern-text)

000089         by -1 until

000090             dir-name-pattern-text(nonblank-len:1) <> space

000091                 or

000092             nonblank-len = 1.

000093*    add 1 to nonblank-len giving terminator-position.

000094     add 1 to nonblank-len giving indix.

000095*    move nonblank-len to indix.

000096     MOVE X"00" TO dir-name-pattern-text(indix:1)

000097*  move function NULL-TERMINATE dir-name-pattern-text

000098*   to arg-text

000099

000100*    move pattern-terminator

000101*        to dir-name-pattern-text(terminator-position:1).

000102

000103* Set desired search attributes by name.

000104     compute search-attributes =

000105             find-file +

000106             find-directory +

000107             find-neither.

000108*    move zero to dirflags.

000109     move 2 to dirflags.

000110

000111* Start the scan -- similar to opening a file.

000112     call 'CBL_DIR_SCAN_START' using

000113                       dir-handle

000114                       dir-name-pattern

000115                       search-attributes

000116                       dirflags

000117                                returning

000118                       search-status.

000119

000120* Read to end, similar to reading a file.

000121     perform walk-dir thru walk-dir-exit until

000122             search-status <> zero.

000123

000124

000125* At end or upon error, end the scan, similar to closing a file.

000126     call 'CBL_DIR_SCAN_END' using

000127                      dir-handle

000128                             returning

000129                      search-status.

000130

000131* End the program.

000132     display 'That''s all!'.

000133     goback.

000134

000135 walk-dir.

000136* Initialize name-text; function does not right-pad to length.

000137     move spaces to name-text.

000138

000139* Do the read.

000140     call 'CBL_DIR_SCAN_READ' using

000141                      dir-handle

000142                      entry-data

000143                              returning

000144                      search-status.

000145

000146     if search-status <> zero exit paragraph.

000147

000148* Remove all but the two rightmost bits of result.

000149     move function MOD(entry-data-attribute, 3) to attrib-work.

000150

000151* Format result display.

000152     evaluate attrib-work

000153         when 1 move 'File' to attrib-text

000154         when 2 move 'Directory' to attrib-text

000155         when other move '???' to attrib-text.

000156         display 'Next entry is: '

000157                attrib-text ' ' name-text(1:name-length).

000158

000159 walk-dir-exit.

* Micro Focus Net Express            V5.0 revision 000 Compiler

* Total Messages:     0

* Data:        2764     Code:         408

0 Likes
Highlighted
New Member.

For COBOL to NON COBOL you could create a GUID in the COBOL program and pass that to the NON COBOL program, the NON COBOL program could use it to write out a file. On return read then delete the file.

This way it could also be thread safe.

Neil

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.