zOs/REXX.O13/CDOS29

/* copy connDir begin **************************************************
   send the file frDsn from the current not
            to the node toNode as toDsn if not empty
            using connect direct
            additional connect direct attributes may be specified
                by arguments 4... (with ,a b, or equifalently , a='b',
***********************************************************************/
connectDirect: procedure
    parse upper arg frDsn, toNode, toDsn
    say 'sending' frDsn 'to' toNode toDsn 'with connect direct'
    call adrTso "alloc shr dd(sysut1) reuse dsn("frDsn")"
    call adrTso "alloc new delete  dd(DDIN) dsn("dsnTemp(connDir)")" ,
                   "recfm(f,b) lrecl(80)"
    call writeDDBegin ddIn
    t.1 = "DEST='"toNode"'"
    t.2 = "DSNCOPY='YES'"
    x=2
    if toDsn ^= '' then do
        x = x + 1
        t.x = "DSN='"dsn2Jcl(toDsn)"'"
        end
    do ax=4 to arg()
        parse upper value arg(ax) with key val
        val = strip(val)
        call trc 'arg' ax':' arg(ax) 'key' key "val '"val"'"
        if key = '' then
            iterate
        x = x+1
        if pos("=", key) > 0 then
            t.x = key val
        else
            t.x = key"='"val"'"
        end
    call writeDD ddIn, t., x
    call writeDDEnd ddIn
    if 1 then do
        call trc 'connectDirect ddIn' x
        do i=1 to x
            call trc i t.i
            end
        end
    call adrTso "call *(OS2900)"
    call adrTsoRc 'free dd(sysut1)'  /* a ghost freed it already */
    call adrTso 'free dd(ddin) delete'
    /* os2900 does not free it dd's, so we do it
                 otherwise the second run will fail... */
    call adrTsoRc 'free dd(ddPrint work01 cmdout dmprint)'
    say 'end connectDirect'
return /* end connectDirect */
/* copy connDir end   *************************************************/