[an error occurred while processing this directive]

HP OpenVMS Systems

ask the wizard
Content starts here

Using smg$execute_command?

» close window

The Question is:

 
How do you tell a sub process to expect input from calls to
smg$execute_command(...)
 
I have created a process, called an image ( written in basic) but all input
lines are hung.
 
When I use the simplest basic program :
10 print "before"
20 input answer$
30 print "input was :";answer$
 
and call this process with execute_command,  the response I get is :
before
input was :$write SMG$STSMBX $STATUS
hang...
 
I have a library of non smg compliant programs that use standard print/input
io routines and would like to couple them to a basic SMG menu system.  the
system works and receives valid output from the sub processes being called,
but cannot get input into t
hem.  Using a COM with embedded input does work but creates inherent
limitations
 
 
Any suggestions
 
Thanks in advance
 
Alex Fry
 


The Answer is :

Example-BASIC  Using SMG$CREATE_SUBPROCESS To Create A Subprocess
 
 
COPYRIGHT (c) 1988, 1993 by Digital Equipment Corporation.
ALL RIGHTS RESERVED. No distribution except as provided under contract.
 
Copyright (c) Digital Equipment Corporation 1991. All rights reserved
LAYERED PRODUCT:  VAX BASIC, V3.4          OP/SYS: VMS, V5.4-2
 
SOURCE:     Digital Customer Support Center
 
 
OVERVIEW:
 
The SMG$CREATE_SUBPROCESS routine creates a DCL subprocess and
associates it with a virtual display.
 
 
*** CAUTION ***
 
This sample program has been tested using VAX BASIC Version 3.4 on
VMS Version 5.4-2.  However, we cannot guarantee its effectiveness
because of the possibility of error in transmitting or implementing
it.  It is meant to be used as a template for writing your own
program and it may require modification for use on your system.
 
 
PROGRAM NOTES:
 
From your main process, you can then specify commands to be executed by
the subprocess using the SMG$EXECUTE_COMMAND routine.  Communication
between the processes is performed using mailboxes, thus allowing you to
control the input commands and the output text.  Before creating the
subprocess, the Screen Management Facility checks to ensure that you
have sufficient resources to create the necessary mailboxes and the
subprocess.  A remaining BYTLM value of at least 5000 and a remaining
PRCLM value of at least 1 are required.
 
This example is modeled after an example taken from "Programming Volume
5C, Run-Time Library Routines", page SMG-47 of the VMS V5.4
documentation set.
 
 
PROGRAM:
 
    PROGRAM create_subprocess
        OPTION TYPE = EXPLICIT
 
        %INCLUDE "$smgdef" %FROM %LIBRARY "sys$library:basic$starlet"
 
        COMMON (abc) LONG num_commands
 
        DECLARE LONG stat, pb_id, vd1, vd2, rows, cols
 
        !
        ! Declare the functions.
        !
        EXTERNAL LONG FUNCTION smg$create_pasteboard,       &
                               smg$create_virtual_display,  &
                               smg$paste_virtual_display,   &
                               smg$create_subprocess,       &
                               smg$execute_command,         &
                               smg$label_border
 
        EXTERNAL LONG completion_routine
 
        !
        ! Establish the pasteboard and virtual displays.
        !
        rows = 24%
        cols = 80%
        stat = smg$create_pasteboard (pb_id,, rows, cols)
        CALL lib$stop (stat BY VALUE) IF (stat AND 1%) = 0%
 
        rows = 12%
        cols = 75%
        stat = smg$create_virtual_display (rows, cols, vd1, smg$m_border)
        CALL lib$stop (stat BY VALUE) IF (stat AND 1%) = 0%
 
        stat = smg$label_border (vd1, "DISPLAY", smg$k_top)
        CALL lib$stop(stat BY VALUE) IF (stat AND 1%) = 0%
 
        rows = 5%
        cols = 75%
        stat = smg$create_virtual_display (rows, cols, vd2, smg$m_border)
        CALL lib$stop (stat BY VALUE) IF (stat AND 1%) = 0%
 
        stat = smg$label_border (vd2, "STATUS", smg$k_top)
        CALL lib$stop (stat BY VALUE) IF (stat AND 1%) = 0%
 
        !
        ! Paste virtual displays on pasteboard.
        !
        rows = 2%
        cols = 2%
        stat = smg$paste_virtual_display (vd1, pb_id, rows, cols)
        CALL lib$stop (stat BY VALUE) IF (stat AND 1%) = 0%
 
        rows = 17%
        cols = 2%
        stat = smg$paste_virtual_display (vd2, pb_id, rows, cols)
        CALL lib$stop (stat BY VALUE) IF (stat AND 1%) = 0%
 
        !
        ! Create the subprocess.
        !
        stat = smg$create_subprocess (vd1, &
                                      LOC(completion_routine) BY VALUE, &
                                      vd2 BY VALUE)
        CALL lib$stop (stat BY VALUE) IF (stat AND 1%) = 0%
 
        !
        ! Execute the DCL commands.
        !
        num_commands = 1%
        stat = smg$execute_command (vd1, "$SHOW DEFAULT")
        CALL lib$stop (stat BY VALUE) IF (stat AND 1%) = 0%
 
        SLEEP 2%
 
        num_commands = num_commands + 1%
        stat = smg$execute_command (vd1, "$SHOW TIME")
        CALL lib$stop (stat BY VALUE) IF (stat AND 1%) = 0%
 
        SLEEP 2%
 
        num_commands = num_commands + 1%
        stat = smg$execute_command (vd1, "$SHOW QUOTA")
        CALL lib$stop (stat BY VALUE) IF (stat AND 1%) = 0%
 
        !
        ! Wait for everything to complete.  We know when everything is
        ! done when 'num_commands' gets to zero.
        !
        SLEEP 5%   UNTIL num_commands <= 0%
    END
 
 
    SUB completion_routine (smg$r_subprocess_info_table smg_info, &
                            LONG r0, LONG r1, LONG pc, LONG psl)
 
        OPTION TYPE = EXPLICIT
 
        %INCLUDE "$smgdef" %FROM %LIBRARY "sys$library:basic$starlet"
 
        EXTERNAL LONG FUNCTION smg$put_line
 
        COMMON (abc) LONG num_commands
 
        DECLARE LONG stat
 
        num_commands = num_commands - 1%
 
        IF (smg_info::smg$l_status AND 1%) <> 0% THEN
           stat = smg$put_line (smg_info::smg$l_usr_arg, "Command completed")
           CALL lib$stop (stat BY VALUE) IF (stat AND 1%) = 0%
        ELSE
           stat = smg$put_line (smg_info::smg$l_usr_arg, "Command failed")
           CALL lib$stop (stat BY VALUE) IF (stat AND 1%) = 0%
        END IF
    SUBEND
 
 

answer written or last revised on ( 12-JAN-2000 )

» close window