Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: Ask Reuben 242 - RUN vs launchUrl  (Read 412 times)
Reuben B.
Four Js
Posts: 1099


« on: August 30, 2024, 01:19:24 am »

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 ?  what environment will the child program launch in, are you in a desktop or web environment ? and are you using Genero Application Server ?

Read more at https://4js.com/ask-reuben/ig-242/
 

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Roland W.
Posts: 15


« Reply #1 on: August 30, 2024, 08:32:13 am »

Hello Reuben,

as an alternative to RUN I'm using the following code:

Code
  1. define l_result  integer,
  2.       l_error  boolean = false,
  3.       l_channel base.channel
  4.  
  5. if ((l_channel := base.channel.create()) is not null)
  6. then
  7. try
  8.   call l_channel.openpipe("ls; echo $?", "r")   # $? contains the return value of the previous command
  9.   if not l_channel.read([l_result])
  10.   then let l_error = true
  11.   else let l_error = (l_result <> 0)   # if return value <> 0, an error occured
  12.   end if
  13. catch
  14.   error "exception caught"
  15. end try
  16. call l_channel.close()
  17. end if

The main advantage is that I can check whether the command was executed successfully because I evaluate the return value. By using RUN this can become tricky (see https://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_programs_RUN.html#c_fgl_programs_RUN__CATCH_EXECUTION_STATUS).

Kind regards
Roland
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines