*****************************************************************************
*                                                                           *
*                           AC/BASIC COMPILER                               *
*                          ===================                              *
*                                                                           *
*     Acquire environment information from runtime commmuncations block.    *
*                                                                           *
* Description:                                                              *
*                                                                           *
*        This routine returns pointers into the runtime communications      *
*        block for you to use in making environment decisions in your       *
*        compiled applications.  This routine will return the command       *
*        line to you if lauched from CLI.  If launched from Workbench,      *
*        you will get a pointer back to the Workbench message.              *
*                                                                           *
* Format of call:                                                           *
*                                                                           *
*        CALL GETARGS( VARPTR(PTR&),VARPTR(THELEN&), VARPTR(LAUNCH&) )      *
*                                                                           *
*                                                                           *
* Entry: None                                                               *
*                                                                           *
* Exit:  PTR&    : Pointer to command line image if launched from CLI       *
*        THELEN& : Length of command line image if launched from CLI        *
*        LAUNCH& : if 0, then CLI launch, else has pointer to WB message    *
*                                                                           *
*                                                                           *
* Note:  To completely understand how this routine (and it's BASIC program) *
*        function, an understanding of the ROM Kernel is fundamental. See   *
*        the ROM Kernel Manual: Libraries and Devices publication for more  *
*        information about Workbench.  Refer to the Exec manual for details *
*        about messages and message passing.  Refer to AmigaDOS technical   *
*        documents for details about the Command Line Interface (CLI)       *
*****************************************************************************
*                                                                           
* Modification History:
*                                                             
* 28 Mar 1988  Original routine for release in AC/BASIC v1.3              CCG
*


*
* Some handy equates into the runtime communications block.  These can be
* found in Appendix D of the AC/BASIC Reference manual.
*
  
LAUNCH  EQU     -68
CMDSTR  EQU     -76
CMDLEN  EQU     -80

        XDEF    GETARG

GETARG: LEA     16(A7),A3               * start at one above last arg
        MOVEQ   #0,D0
        MOVE.L  -(A3),A1                * get pointer to launch variable
        MOVE.L  LAUNCH(A0),(A1)         * 0 = CLI, else WB
        MOVEA.L -(A3),A1                * get pointer to length variable
        BNE     NOTCLI                  * clear length/image pointer if WB
        MOVE.L  CMDLEN(A0),(A1)         * set up the length
        MOVEA.L -(A3),A1                * get handle to command image
        MOVE.L  CMDSTR(A0),(A1)         * set up the command image
        RTS                             * finished
NOTCLI: MOVE.L  D0,(A1)                 * return 0 in command length
        MOVEA.L -(A3),A1
        MOVE.L  D0,(A1)                 * and in the command image pointer
        RTS

	END
