Ask Reuben

RUN vs launchURL

What is the difference between using RUN WITHOUT WAITING and the launchUrl front-call to start a child program?

There are a number of techniques you can use to start a child program.  Key factors to take into your decision making include do you want the parent program to wait for the child program to finish?  what information needs to be passed from the parent program to the child ?  are you in a desktop or web environment ? and are you using Genero Application Server ?

The most common technique is to use the RUN command passing an argument that is a string containing the command to start a Genero application.  This will typically be fglrun program optionally followed by some arguments. If you use the RUN WITHOUT WAITING form of the RUN command, the parent program will not wait for the child program, otherwise the parent program will wait for the child program to finish. Use the RUN RETURNING syntax if you want to capture an exit status of the child program.

  • RUN "fglrun program" WITHOUT WAITING – do not wait for the child program to finish
  • RUN "fglrun program" RETURNING result – wait for the child program to finish, capture the exit status
  • RUN "fglrun program" – wait for the child program to finish, ignore the exit status

The child program inherits the environment of the calling program.  As it inherits FGLSERVER  then it uses the same front-end as the calling program and should already have the correct environment for database connections etc.  You can change the environment as part of the command that is passed to RUN.  The exact syntax will depend on the operating system of the back-end server but will be something like RUN “export env-variable=value; fglrun program”.

Ideally the child program is setup to also receive arguments. Code patterns like …

ON ACTION view_details
    RUN SFMT("fglrun account_enquiry --account-number %1", arr[arr_curr()].account_number)

… enable you to pass details from the parent program to the child program.  In this case I am passing the account number related to  the current row in order to launch a child program to view details for that account.  The child program uses base.Application methods or the getopt library to interpret the arguments received.

The browserMultiPage and desktopMultiWindow presentation styles can be used to control if the child program launches in a new browser tab / new desktop window or not.

In Web environments using the Genero Application Server, you also have the option of using launchUrl front-call to launch child programs.  This technique does not wait for the child program to finish.  As it does not wait for the child program to finish, it is not possible to return an exit status to the calling program.  The url value is the same as if you had typed a value into the browser, so there needs to be an application configured in the Genero Application Server configuration.

The line of code will be something like …

CALL ui.Interface.frontCall("standard","launchUrl",SFMT("%1/ua/r/program_xcf",FGL_GETENV("FGL_WEBSERVER_SERVER_NAME"),[],[])

where

  • program_xcf is the name of the application entry in the GAS configuration.
  • The FGL_GETENV(“FGL_WEBSERVER_SERVER_NAME”) line is used to put the same web server into the URL.

With the launchUrl front-call, the application environment is as configured in the .xcf file.  The child program does not inherit the parent application.

With the launchUrl front-call if you want to pass information to the child program then this will arguments as part of the Url.  So the calling line might be something like …

CALL ui.Interface.frontCall("standard","launchUrl",SFMT("%1/ua/r/program_xcf?Arg=account_number&Arg=%2",FGL_GETENV("FGL_WEBSERVER_SERVER_NAME", arr[arr_curr()].account_number),[],[])

In a web environment, the child program will appear in a seperate browser tab.

Prior to Genero 4.00, the fact that launchUrl program would appear in a seperate browser tab meant that an additional user license would be consumed.  This was resolved with Genero 4.00 as per the first entry in the New Features section of the documentation.

Applications launched via StartMenu are the equivalent of RUN or RUN WITHOUT WAITING depending on the value of the waiting attribute in the StartMenuCommand node.  When using TREE instead of StartMenu then the equivalent is the ON ACTION triggered by the double click executing a RUN or RUN WITHOUT WAITING.

RUN WITHOUT WAITING is the most popular syntax used to start child programs.  I would typically expect this to be coded via a library function.