zOs/REXX.O13/MEM

/* copy mem begin  ****************************************************/
/**********************************************************************
***********************************************************************/
inAll: procedure expose m.
parse arg m, pTyp, pOpt, out
    call inBegin m, pTyp, pOpt
    if out == '' then do
        call inBlock m, '*'
        if inBlock(m) | m ^== m.in.m.block then
            call err 'not eof after inBlock *'
        end
    else do
        rx = 0
        do while inBlock(m)
            bl = m.in.m.block
            do ix=1 to m.bl.0
                rx = rx + 1
                m.out.rx = m.bl.ix
                end
            end
        m.out.0 = rx
        end
    call inEnd m
    return
endSubroutine inAll

inBegin: procedure expose m.
    parse arg m, pTyp, pOpt
    m.in.m.type = pTyp
    m.in.m.rNo = 0
    m.in.m.bNo = 0
    m.in.m.0   = 0
    m.in.m.eof = 0
    m.in.m.block = m
    inf = ''
    if pTyp == 's' then do
        m.in.m.string.0 = 1
        m.in.m.string.1 = pOpt
        m.in.m.block = string
        m.in.m.type = 'b'
        end
    else if pTyp == 'b' then do
        m.in.m.block = pOpt
        end
    else if pTyp == 'd' then do
        m.in.m.dd = pOpt
        inf = 'dd' pOpt
        end
    else if pTyp == 'f' then do
        m.in.m.type = 'd'
        m.in.m.dsn = pOpt
        if verify(m, '0123456789') = 0 then
            m.in.m.dd = 'in'm
        else
            m.in.m.dd = m
        inf = 'dd' m.in.m.dd 'dsn' pOpt
        call adrTso 'alloc dd('m.in.m.dd') shr dsn('pOpt')'
        end
    else
        call err 'inBegin bad type' pTyp
    m.in.m.info = pTyp'-'m.in.m.type inf
    return
endProcedure in

inLine: procedure expose m.
parse arg m
    r = m.in.m.rNo + 1
    if r > m.in.m.0 then do
        if ^ inBlock(m) then
            return 0
        r = 1
        end
    m.in.m.line = m.in.m.block'.'r
    m.in.m.rNo = r
    return 1
endProcedure inLine

inBlock: procedure expose m.
parse arg m, cnt
    if m.in.m.type == 'd' then do
        m.in.m.bNo = m.in.m.bNo + m.in.m.0
        m.in.m.eof = ^ readNext m.in.m.dd, m'.'m.in.m'.', cnt
        return ^ m.in.m.eof
        end
    else if m.in.m.type == 'b' then do
        if m.in.m.bNo > 0 then do
            m.eof = 1
            return 0
            end
        m.in.m.bNo = 1
        b = m.in.m.block
        m.in.m.0 = m.b.0
        return 1
        end
    else
        call err 'inBlock bad m.in.'m'.type'      m.in.m.type
endProcedure inBlock

inLineInfo: procedure expose m.
parse arg m, lx
    if lx = '' then
        lx = m.in.m.rNo
    cl = m.in.m.block'.'lx
    return 'record' (lx + m.in.m.bNo) ,
           '(m.'cl 'type' strip(m.in.m.info)'):' m.cl
endProcedure inLineInfo

inEnd: procedure expose m.
parse arg m
    if m.in.m.type == 'd' then do
        call readDDEnd m.in.m.dd
        end
    else if m.in.m.type == 'f' then do
        call readDDEnd m.in.m.dd
        call adrTso 'free dd('m.in.m.dd')'
        end
    return
endProcedure inEnd
/* copy mem end   *****************************************************/