OK - here's a sample of "parent.kix" and "child.kix" that illustrates one way to do this - first, the PARENT script:


; PARENT.KIX ====================================================== 
Break On
; Will spawn off 10 child processes. Each child will take two arguments. The first arg will be 
; the child's ID, the second represents something to do.. 
; The child will perform a task, write the answer to a temporary INI file, then rename the ini 
; file before exiting (simulating lots of work being done by the child, writing much data to the ini file) 
 
; The parent will monitor the folder for the INI files, read them when they appear, and 
; consolidate the data. The INI files will be deleted by the parent process when complete. 
 
$ = SetOption('NoVarsInStrings', 'On')
 
Del '.\Summary.txt'		; start with a fresh "central database" for logging the results 
 
$Data = ' AaAbAcAdAeBaBbBcBdBeCaCbCcCdCeDaDbDcDdDe'
 
$Count = 1				; count of tasks to process 
$Workers = 0				; count of active workers 
 
While $Count < 16			; max of 15 
 
  ; limit number of child processes 
  If $Workers < 10
    ; fewer than 10 workers - start one! 
    ; just a silly command here to pass the count and two characters from the data string 
    ; in real world, A1 would be an ID (as it is here) and A2 might be the name of the remote system 
    ; that the child should interrogate 
    $Command = 'kix32.exe .\child.kix $A1=' + $Count + ' $A2="' + SubStr($Data, $Count * 2, 2) + '"'
    Run $Command			; run asynchronously 
    $Workers = $Workers + 1		; increment the worker count 
    $Count = $Count + 1			; increment the process count 
  EndIF
 
 
  ; Process completed work, allowing more children to run 
  ; any INI files found? 
  $File = Dir('*.ini')
  While $File <> "" and @ERROR = 0
    ; Yes! 
    $Workers = $Workers - 1		; worker completed, reduce the active count 
 
    ; write the data from the child's INI file to the "central database" 
    $ = RedirectOutput('.\summary.txt')
    $File ', '
    ReadProfileString('.\' + $File, 'Common', 'Arg') ?
    $ = RedirectOutput('')
 
    ; remove the worker file 
    Del '.\' + $File
 
    ; check for more as long as we're here.. 
    $File = Dir()  ; retrieve next file 
  Loop
 
  ; display status 
  ' Count: ' $Count ',  Workers: ' $Workers '   ' Chr(13)
 
Loop
 
; no more children to run, need to process remaining files that are waiting for completion 
While $Workers > 0
  $File = Dir('*.ini')
  While $File <> "" and @ERROR = 0
 
    ; found a file - that means a worker completed it's task 
    $Workers = $Workers - 1
 
    ; update the "central database" 
    $ = RedirectOutput('.\summary.txt')
    $File ', '
    ReadProfileString('.\' + $File, 'Common', 'Arg') ?
    $ = RedirectOutput('')
 
    ; delete the worker file 
    Del '.\' + $File
 
    ; Status display 
    ' Count: ' $Count ',  Workers: ' $Workers '   ' Chr(13)
    Sleep 0.2
 
    ; any more files ready? 
    $File = Dir()  ; retrieve next file 
  Loop
Loop
 
?
' Displaying results:' ?
Display 'Summary.txt' ?
 
quit 0
 
 
 

And the CHILD script:


; CHILD.KIX ======================================================= 
; simple example of a child process 
Break On
 
; Args are $A1 and $A2 
 
SRnd(@TICKS)
; simulate doing lots of work... Wait a random amount of time, between 0 and 4 seconds 
Sleep Rnd(4)
 
$IniFile = '.\file_' + $A1
$TmpFile = $IniFile + '.tmp'
$IniFile = $IniFile + '.ini'
 
$ = WriteProfileString($TmpFile, 'common', 'Arg', $A2)
 
; simulate doing more work... 
Sleep Rnd(4)
 
; work is done, no more updates to the INI file, rename it so the Parent will find it 
Move $TmpFile $IniFile
 
; exit success! 
Exit 0
 

The CHILD waits 0-4 seconds, then creates a .TMP file, waits an additional 0-4 seconds (to simulate work communicating to a remote system) and then renames the TMP file to INI before exiting.

PARENT quickly spawns off 10 children, then waits for INI files to appear. Each INI that appears reduces the worker count, allowing more children to be run, until all 15 have completed. The status line shows the count grow from 1-15, and the workers increase to 10, then decrease/increase until all 15 tasks have been initiated, and finally workers decreases to zero.

Again, it's a simple, silly example that illustrates the concept, but should be able to form the building block of what you need. You should probably incorporate a max time limit that you wait for workers to complete, or use some type of process interrogation so you don't wait for children that die before completing their tasks. Unlikely, but possible.

Hope this gets you going in the right direction! I tested this, and it should work to illustrate the concept just fine - using Kix 4.60 here..

Glenn

_________________________
Actually I am a Rocket Scientist! \:D