Quick start: run without waiting

The Genero Web Client for JavaScript (GWC-JS) provides a mechanism for applications to be run as child programs that execute in the background, that is the parent program can continue to run without waiting for the child program to finish.

About this task:

The example BDL program (Navigation.42m) starts an application with stacked windows. It gives you the option to use a RUN WITHOUT WAITING command to start another instance of the application as a background process.

  1. Copy the sample BDL program code to a text file and save it as Navigation.4gl The program's main code block opens four windows and displays form menus.
    # 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.
    
    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. Copy the program's form specification code to a text file and save it as 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. At the command line, compile the source code modules you have created (Navigation.4gl and Navigation.per) by typing the following commands: Run :
    fglcomp Navigation.4gl
    fglform Navigation.per
    Compiled files are created for the source code module and the form:

    Navigation.42m.
    Navigation.42f

  4. Create an application configuration file. Use a text editor or if you are using Studio, go to File >> New >> Web/AS >> Application Configuration (.xcf) Provide an absolute path to the location of your compiled application file in the PATH element, and in the MODULE element specify that Navigation.42m is the module required to launch your application.
    <?xml version="1.0" encoding="UTF-8" ?>
    <APPLICATION Parent="defaultgwc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
          xsi:noNamespaceSchemaLocation="http://www.4js.com/ns/gas/3.00/cfextwa.xsd">
     <EXECUTION>
          <PATH><path_to_your_local_directory></PATH>
          <MODULE>Navigation.42m</MODULE>
     </EXECUTION>
     <UA_OUTPUT>
        <GWC-JS>gwc-js</GWC-JS>
     </UA_OUTPUT>
    </APPLICATION>
  5. Save the configuration file (e.g. Navigation.xcf) in your $(res.appdata.path)/app directory.
  6. Start the GAS standalone dispatcher from the command line using httpdispatch and open the Navigation application in your browser by entering the URL:

    http://localhost:6394/ua/r/Navigation

    Figure 1. Current Application Window in GWC-JS
    Genero Web Client showing the Navigation application's current window

    • The current window at the top of the stack (W3) is displayed in the GWC-JS user interface. The current window's menu button options are:
      • w1
      • w2
      • w3
      • Screen
      • RWW
      • Exit
    • The Window name field displays W3 for the current window.
    • The Is current field displays YES for the current window.
    • The side bar panel is updated with the Navigation tree, which has the following links to windows in the stack:
      • Screen
      • Window w1 - 1
      • Window w2 - 1
      • Window w3 - 1
  7. To have another instance of the Navigation application running at the same time: In the current window's Test menu panel, select the RWW menu button. The side bar view is updated with another Navigation tree.

    Figure 2. Two Instances of Application Running in GWC-JS
    Genero Web Client user interface showing two instances of the Navigation application running

  8. From the side bar view, select the current windows in each running instance of the Navigation application, for example complete the following steps:
    1. Select Window w3 - 1
    2. Select Window w3 - 2

    You should see that both applications have current windows. The first instance of the Navigation application you started (the parent program) continues to run without waiting for the second instance of Navigation (the child program) to finish. The result of your selection will depend on the following:

    • If the selected window is the current window, the Is current field value is YES and the Test menu panel is displayed.
    • If the selected window is not current, the Is current field value is NO and the Test menu panel is not displayed.