/* $VER: runargs.rexx 3.0 (5.1.2001) #AREXX © Roger Hågensen You need the WBStartEmu archive to use the WB mode of this script. You can get the latest version at http://www.stephan-rupprecht.de/ */ OPTIONS RESULTS OPTIONS FAILAT 21 PARSE ARG Arguments opts.Mode='CLI' opts.Stack=8192 opts.Command='' opts.Args='' opts='MODE/A,STACK/K/N,COMMAND/A,ARGS/F' IF Arguments='?' THEN DO SAY opts EXIT 10 END IF Strip(Arguments)='' THEN DO SAY 'No args!' EXIT 10 END IF ~Show('L','rexxsupport.library') THEN CALL AddLib('rexxsupport.library',0,-30) IF ~Show('L','rexxdossupport.library') THEN CALL AddLib('rexxdossupport.library',0,-30,0) IF ~ReadArgs(Arguments,opts,'opts.') THEN DO SAY Fault(RC) EXIT 10 END IF opts.Command='' THEN DO SAY 'No command defined!' EXIT 10 END opts.Mode=Upper(opts.Mode) PARSE VAR opts.Args opts.ArgsA'[]'opts.ArgsB opts.ArgsA=Strip(opts.ArgsA) opts.ArgsB=Strip(opts.ArgsB) IF opts.ArgsA~='' THEN opts.ArgsA=' '||opts.ArgsA IF opts.ArgsB~='' THEN opts.ArgsB=' '||opts.ArgsB oldstack=Pragma('STACK',opts.Stack) ADDRESS WORKBENCH GETATTR WINDOWS.ACTIVE VAR activewin GETATTR WINDOW.ICONS.SELECTED.0.NAME NAME '"'||activewin||'"' VAR activeicon IF activeicon='ACTIVEICON' THEN activeicon='' IF activewin='root' THEN DO activewin=activeicon||':' activeicon='' END ELSE IF (Right(activewin,1)=':')=0 THEN activewin=activewin||'/' wbfile=activewin||activeicon IF (wbfile=':') | (wbfile='/') THEN wbfile='' ELSE wbfile=' "'wbfile'"' IF opts.Mode='WB' THEN ADDRESS COMMAND wbrun '"'||opts.Command||'"'||wbfile ELSE ADDRESS COMMAND '"'||opts.Command||'"'||opts.ArgsA||wbfile||opts.ArgsB oldstack=Pragma('STACK',oldstack) EXIT 0