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: Get child count - MDI (using 4sm file)  (Read 14831 times)
Giridara P.
Posts: 6


« on: August 18, 2015, 07:59:15 am »

Hi

I want to get the child count (child instances)  while running the child program.
I am using getchildcount() from the parent program for getting the child count. But, I am using 4sm files in an MDI container.

<StartMenuCommand text='Employee master' exec = fglrun /usr1/dvlp/giri/childprog.42r'/>

while executing child program, how to check how many programs are opened and
what are all the child instance running for the parent.

Giridar
Sebastien F.
Four Js
Posts: 545


« Reply #1 on: August 18, 2015, 09:07:55 am »

Hello Giridar,

Can you elaborate please?

Is ui.Interface.getChildInstances("child_name") not returning the expected value?

What front-end are you using?

Executing a child program from a start menu is similar to a RUN "fglrun program".
I see no reason why getChildInstances() would not work with a start menu.

Did you properly configure the parent and child programs for Window Containers (i.e. MDI)?

Maybe you made a mistake in the name of the parent and child programs, each must be identified with a name and have a type:

Parent:
Code
  1. MAIN
  2.  CALL ui.Interface.setName("parent1")
  3.  CALL ui.Interface.setType("container")
  4.  ...
  5.  

Child:
Code
  1. MAIN
  2.    CALL ui.Interface.setName("custapp")
  3.    CALL ui.Interface.setType("child")
  4.    ...
  5.  

See:
https://4js.com/online_documentation/fjs-fgl-manual-html/?path=fjs-fgl-manual#c_fgl_mdi_windows_005.html

And also FGLDIR/demo/Containers...

Seb
Giridara P.
Posts: 6


« Reply #2 on: August 18, 2015, 09:25:16 am »

Hi Sebastien F

Thanks for your response Sebastien. I do understand what you are saying and i agree and its working fine with me.

But my query is: Once i execute the child program the control is in a child prog. At this juncture i need to know how many child programs are running at that time.

How do you restrict a same program being called twice.

Giridar
Sebastien F.
Four Js
Posts: 545


« Reply #3 on: August 18, 2015, 11:08:31 am »

Ok I understand now.

The start menu is declarative, and has no option to check if WCI child programs are already started.

I see different solutions:

1) Instead of using a start menu, if there are not too much possible child programs, consider using a TOPMENU in the WCI container to start child programs with a real RUN "fglrun xxx", with a TOPMENU you have total control in the parent program (ON ACTION, disable actions)... Note that a TOPMENU can be build at runtime with the om.* interface.

2) Use the start menu, but in each child program, check that it is not yet started for the current user (ps, etc), but this tricky and OS/user dependant.
Maybe here we are missing a ui.Interface.getProgramInstances("prog_name"), to let each WCI child program check itself if it is not yet started (from a front-end point of view)

3) You could also write your own self-made start menu with a treeview. This may be a good opportunity to customize the way you want to start child programs.

4) Use the start menu, but instead of doing directly a "fglrun prog" command, use a shell script, to implement child program instance checking and refuse to start if it is already started for this user.. can give visual feedback by starting another program just showing message "This program is already started"...?

Maybe there are other solutions.

Seb
Giridara P.
Posts: 6


« Reply #4 on: August 18, 2015, 12:35:51 pm »

Hi Seb,

Thanks for your solutions. In topmenu, i am unable to disable(hide or Grey) the options. Hence i moved to startmenu.

I cannot adopt auitree logic.

Let us know what are the script commands to find the child instances.




G
Sebastien F.
Four Js
Posts: 545


« Reply #5 on: August 18, 2015, 01:52:41 pm »

Assuming you have a static struture of program groups, TOPMENU is my prefered solution.
With a TOPMENU, associate ON ACTION handlers, and disable/enable options with DIALOG.setActionActive("runprog1", FALSE/TRUE)...
But if the program groups structure is variable (build at runtime), and/or if there a hundreds of program, TOPMENU is not adapted.

Seb
Giridara P.
Posts: 6


« Reply #6 on: August 18, 2015, 02:27:32 pm »

Yes seb exactly, my main program's had more then 1000 child program. It is build runtime.

Let us know any other solution or how will find out child count in shell script.

G
Reuben B.
Four Js
Posts: 1119


« Reply #7 on: August 19, 2015, 06:08:12 am »

I'll throw two suggestions into the mix that you maybe able to expand on that gets you something you can work from...

1. Have all your programs call a library function when they start, and when they finish.  In the library function called when the program starts, insert into a table information such as user-name, program, PID, PPID, start-time, command line arguments etc.  In the library function called when the program ends, update this row with the finish-time.  If there is a row in this table that matches the program name and finish-time is NULL then you know there is a running instance of this program.  (Note: you will need to cater for the case where a program crashes which can be done using the PID)

2. Look at the output of fglWrt -a info users.  Whilst it doesn't show the program name, you can find it from the process id.  Whilst its not trivial, you maybe able to use the base.Channel methods to get what you are looking for.

Reuben

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines