Run without waiting

Complete this demonstration to see what happens when you launch a second application using RUN ... WITHOUT WAITING.

With the Genero Browser Client, applications started with RUN ... WITHOUT WAITING appear in the same browser tab as the application that executed the RUN ... WITHOUT WAITING command. You can use the application list sidebar to switch between applications.
Tip:

For information regarding RUN ... WITHOUT WAITING and how it works across the Genero front-ends, see Containers for program windows in the Genero Business Development Language User Guide.

About this demonstration

For this demonstration, you will create and run a simple Genero application that includes multiple windows. You will be able to switch between windows using the window list. The application also includes a menu option that launches a new instance of the application using the RUN WITHOUT WAITING command. You will be able to switch between the applications using the application list in the sidebar.

Before you begin

Start the standalone dispatcher from the command line using httpdispatch.

Tip:

Launch the Genero Workplace Window to ensure an environment suitable for Genero commands.

Open the demos application in your browser by entering the URL:
http://localhost:6394/ua/r/gwc-demo

  1. Create the Navigation app source. Copy and save the following Genero source as a file named Navigation.4gl:
    MAIN
      DEFINE cw STRING
      DEFINE i INT
    
      IF num_args() = 0 THEN LET i=1 ELSE LET i=arg_val(1) END IF
    
      OPEN FORM f FROM "Navigation"
      DISPLAY FORM f
      DISPLAY "screen" TO fname
    
      OPEN WINDOW w1 WITH FORM "Navigation"
      CALL fgl_setTitle("Window w1 - " || i)
      DISPLAY "w1" TO fname
    
      OPEN WINDOW w2 WITH FORM "Navigation"
      CALL fgl_setTitle("Window w2 - " || i)
      DISPLAY "w2" TO fname
    
      OPEN WINDOW w3 WITH FORM "Navigation"
      CALL fgl_setTitle("Window w3 - " || i)
      DISPLAY "w3" TO fname
    
      WHILE 1
        DISPLAY "YES" TO info
        MENU "Test"
          COMMAND "w1"      LET cw="w1" EXIT MENU
          COMMAND "w2"      LET cw="w2" EXIT MENU
          COMMAND "w3"      LET cw="w3" EXIT MENU
          COMMAND "screen"  LET cw="screen" EXIT MENU
          COMMAND "RWW"     RUN "fglrun Navigation " || i+1  WITHOUT WAITING
          COMMAND KEY(INTERRUPT) "Exit" EXIT PROGRAM
        END MENU
        DISPLAY "NO" TO info
        CASE cw
          WHEN "w1" CURRENT WINDOW IS w1
          WHEN "w2" CURRENT WINDOW IS w2
          WHEN "w3" CURRENT WINDOW IS w3
          OTHERWISE CURRENT WINDOW IS SCREEN
        END CASE
        DISPLAY "YES" TO info
      END WHILE
    END MAIN
    Note:

    The "RWW" menu command contains the instruction which allows you to start another instance of the application:

    COMMAND "RWW" RUN "fglrun Navigation " || i+1  WITHOUT WAITING
  2. Create the Navigation app form. Copy and save the following Genero form definition as a file named Navigation.per:
    # Property of Four Js*
    # (c) Copyright Four Js 1995, 2015. All Rights Reserved.
    # * Trademark of Four Js Development Tools Europe Ltd
    #   in the United States and elsewhere
    #
    # Four Js and its suppliers do not warrant or guarantee that these
    # samples are accurate and suitable for your purposes. Their inclusion is
    # purely for information purposes only.
    
    LAYOUT
    GROUP(text="Test Current Window")
    GRID
    {
    Window name [fw         ]
    Is current  [info       ]
    }
    END
    END
    ATTRIBUTES
      LABEL fw=formonly.fname;
      EDIT info=formonly.info;
    END
  3. Compile the Navigation app. From the command line, compile the source code modules you have created (Navigation.4gl and Navigation.per) by typing the following commands:
    $ fglcomp Navigation.4gl
    $ fglform Navigation.per

    Compiled files are created: Navigation.42m and Navigation.42f.

  4. Create the Navigation app configuration file. Create an application configuration file for your application. Save the configuration file (Navigation.xcf) in your $(res.appdata.path)/app directory.
    <?xml version="1.0" encoding="UTF-8" ?>
    <APPLICATION Parent="defaultgwc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:noNamespaceSchemaLocation="https://4js.com/ns/gas/3.00/cfextwa.xsd">
     <EXECUTION>
          <PATH>*path_to_your_directory*</PATH>
          <MODULE>Navigation.42m</MODULE>
     </EXECUTION>
     <UA_OUTPUT>
        <PUBLIC_IMAGEPATH>$(res.public.resources)</PUBLIC_IMAGEPATH>
        <GBC>_default</GBC>
     </UA_OUTPUT>
    </APPLICATION>
  5. Run the Navigation app by entering the URL: http://localhost:6394/ua/r/Navigation.
    The application displays.
    Figure: Run a single application


    The current window at the top of the stack (Window w3-1) displays. The menu options are w1, w2, w3, screen, RWW, and Exit. The Window name field displays w3 for the current window. You can use the window list to change which window displays. The sidebar and its application list do not display, as only one application is running.

  6. Click the RWW button to launch a second instance of the Navigation app.
    The second application displays in the same browser tab.
    Figure: Run a second application without waiting for the first application to finish


    The sidebar displays two applications in its application list. Use the sidebar to switch between the applications.

    Notice that both applications have current windows; the first instance of the Navigation application (the parent program) continues to run without waiting for the second instance of the Navigation application (the child program) to finish.

    If the selected window is not the current window, the window list has an arrow. Click this arrow to return to the current window.