## Creating APL child tasks under program control

### Creating a new APL task object

You can create child tasks under program control using the 'APL' System Class. This works as follows:

                ChildTask„'Ś' ŚNEW 'APL'

This creates a task object, but the APL task itself does not start running until you call the `Open` method. Before doing that, you can set various properties of the new task:

#### Specifying whether the task runs in the background

By default, child tasks you create will have their own session window. However, if you set the `background` property to 1, the task will not have a session window and all its output will be thrown away (you must set this property before calling the `Open` method).

#### Specifying the workspace size

By default, a new child task is allocated the amount of workspace which you have set as the default using the Preferences dialog. The `wssize` property allows you to specify a different size, as a value in bytes. If you ask for a very small value, a minimum value of around 100KB will be allocated. If you ask for a very big value, the operating system may allocate a smaller value. A value of 0 means 'use the default'. You must set the `wssize` property before calling the `Open` method, but you can read it back at any time.

#### Specify which machine the task should run on

If you are running a Client-Server implementation of APLX, you can set the `host` property of the APL object to specify on which machine the new APL task should run. You must do this before starting the task.

If you have purchased APLX64, your child APL sessions can comprise a mixture of 32-bit and 64-bit tasks. A 32-bit task can start a 64-bit task, and vice versa.

#### Specifying whether the task's session window is visible

A task which is not a background task will have a session window associated with it, but it may not be visible. You can use the `visible` property (or the `Show` and `Hide` methods) to control whether it is shown, just as you would with any other window. This can be done before or after the `Open` method has been called. You can also use the `where` and `size` properties to set or read the position and size of the task's session window.

### Starting the APL task

The actual APL task starts when you call the `Open` method. If the task has a session window, it will be created at this time, and it will appear unless the `visible` property is 0. If the task has a `background` property of 1, nothing will appear. The child task inherits the ŚMOUNT table of its parent, so will initially have the same mapping from library numbers to operating-system directories.

#### Example

This sequence creates a child task with its own visible session window, and a workspace size of approximately 1MB:

          ChildTask„'Ś' ŚNEW 'APL'
          ChildTask.wssize„1E6
          ChildTask.Open

You can enquire about the visibility and coordinates of the session window as follows:

          ChildTask.visible
    1
          ChildTask.where
    12 32 24 64

You can change the size and position of the task's session window as you would with an ordinary window:

          ChildTask.where„4 10 16 50

Topic: APLX Help : Multi-tasking support : Creating APL child tasks under program control

[ Previous | Next | Contents | Index ]