Question ID : 110
Created on 2009-11-05 at 3:55 PM
Author : Veryant Support [email@example.com]
Online URL : http://support.veryant.com/support/phpkb/question.php?ID=110
CALL CLIENT "C$RUN" USING "C:Program FilesMicrosoft OfficeOFFICE11excel.exe".In order to identify whether excel.exe is installed and its disk location you could read the registry using CALL CLIENT with the registry library routines such as REG_OPEN_KEY and REG_QUERY_VALUE. But a better way is to call the Windows ShellExecute API function instead. Continue reading. 2. CALL CLIENT "ShellExecuteA" ... The Windows API ShellExecute function opens or prints a specified file. This function is located in shell32.dll. You can use the ShellExecute function to start an application assocated with a given document extension without knowing the name of the associated application. For example, you could start the Paintbrush program by passing the filename ARCADE.BMP to the ShellExecute function. For example, the following program will open file.csv with whatever application is associated with the .csv file extension. If Microsoft Excel is installed on the system then it is most likely the application that will launch:
ID DIVISION. PROGRAM-ID. LAUNCHCSV. DATA DIVISION. WORKING-STORAGE SECTION. 78 SW-SHOWNORMAL VALUE 1. 77 RETURN-VAL USAGE LONG. PROCEDURE DIVISION. MAIN-LOGIC. * SEE http://support.microsoft.com/kb/238245 CALL CLIENT "C$SETENV" USING "dll_convention", "1". CALL CLIENT "shell32.dll". CALL CLIENT "ShellExecuteA" USING BY VALUE 0, BY REFERENCE "open", BY REFERENCE "file.csv", BY REFERENCE "", BY REFERENCE "", BY VALUE SW-SHOWNORMAL RETURNING RETURN-VAL. IF RETURN-VAL < 32 THEN DISPLAY "ERROR: ShellExecute() returned ", RETURN-VAL END-IF. STOP RUN.See http://support.microsoft.com/kb/238245 and http://support.microsoft.com/kb/170918 or search for ShellExecute at http://msdn.microsoft.com for more information. 3. CALL CLIENT "MYPROG" (where MYPROG is a COBOL program) If a program named MYPROG is available in the client-side class path, then a program running on the server can call it using CALL CLIENT "MYPROG" and can pass it input, output or input-output parameters of any type by reference or by value just as if it was calling the program on the server. For example, you could compile the following program and add it to your client-side jar file or have your installer put it on the client in the class path specified when your users launch the thin client:
ID DIVISION. PROGRAM-ID. MYCALC. PROCEDURE DIVISION. CALL "C$RUN" USING "calc".You could call this program from your application with: CALL CLIENT "MYCALC". Note that there are differences in behavior of C$RUN/C$SYSTEM between isCOBOL and ACUCOBOL-GT. For example, calls relying on UNIX/Linux shell syntax for redirection of standard streams should be made using the SYSTEM routine. See http://www.veryant.com/support/phpkb/question.php?ID=113 for more information and workarounds for C$RUN/C$SYSTEM if you need platform specific functionality.
Back to Original Question