#-h- spsym            243  asc  10-nov-80 13:37:33  [002,100]
# offsets into tcspwn descriptor
 define(CMD_LENGTH,1)
 define(CMD_ADDRESS,2)
 define(CMD_TYPE,3)
 define(ARG_LENGTH,4)
 define(ARG_ADDRESS,5)

# values of CMD type field
 define(TS.USE,0)
 define(TS.DOL,2)
 define(TS.DOT,1)
 define(TS.INS,3)
#-h- spawns          1035  asc  10-nov-80 13:37:33  [002,100]
 integer function spawn(image, args, pid, wait)

 character mcrlin(80), image(ARB), args(ARB), pid(ARB), wait
 character clower
 integer mcr, spdesc(5), status
 integer equal, length, tcspwn

 string local "local"

 if (clower(wait) != WAIT)
    return(ERR)
 call scopy(image, 1, mcrlin, 1)
 call fold(mcrlin)
 if (equal(mcrlin, local) == YES)
    {
    call scopy(args, 1, mcrlin, 1)
    mcr = YES
    spdesc(ARG_LENGTH) = 0
    spdesc(CMD_TYPE) = TS.DOL
    }
 else
    {
    mcrlin(1) = BLANK
    call scopy(image, 1, mcrlin, 2)
    mcr = NO
    spdesc(ARG_LENGTH) = length(args)
    call getadr(spdesc(ARG_ADDRESS), args)
    spdesc(CMD_TYPE) = TS.USE
    }
 call upper(mcrlin)
 spdesc(CMD_LENGTH) = length(mcrlin)
 call getadr(spdesc(CMD_ADDRESS), mcrlin)
 repeat
    {
    status = tcspwn(spdesc)
    switch(spdesc(CMD_TYPE))
	{
	case TS.DOL:	spdesc(CMD_TYPE) = TS.DOT
	case TS.DOT:	spdesc(CMD_TYPE) = TS.INS
	default:	mcr = NO
	}
    }
 until (mcr == NO | status != EOF)
 if (status != OK)
    status = ERR
 return(status)
 end
