Contents page

Rules for Tools/doscall()


doscall()
SYNOPSIS
     long doscall(long (*routine)(), long par1, ...);

ARGUMENTS
    `long (*routine)()'
          Pointer to function.

    `long par1, ...'
          Up to 8 parameters.

DESCRIPTION
     `doscall()' provides a mechanism for making AmigaDos calls from
     within a task.  Normally, a program running within a task will
     crash if it attempts to read or write to disk.  Because Bars&Pipes
     creates a task to run a Tool's control window code, control
     windows cannot access AmigaDos directly.  `doscall()' solves this
     problem by transferring a file i/o routine that you provide to the
     main Bars&Pipes process, which runs the routine for you.

     To use `doscall()', write a routine to do everything you need to do
     (for example, open a file, read from it, and close the file) and
     pass the routine to `doscall()' as the first parameter.  Up to
     eight parameters may follow.  Here's an example routine that
     writes a file.

          savedata(data) long data; {
    long file = (*functions->fastopen)("datafile",MODE_NEWFILE);
    (*functions->fastwrite)(file,&data,4);
    (*functions->fastclose)(file); }

    /* To call savedata from a task: */

    (*functions->doscall)(savedata,data);