On 21/07/2013 7:15 PM, John McKown wrote:
Such as? I will grant that REXX is "old". But so are PERL, awk, and many
other UNIX tools. Him, perhaps lua. But there is a port of lua to z/OS. A
person here was kind enough to send it to me.

If anybody is interested in Lua drop me a line. I've been having lots of fun with it and have recently been getting my feet wet with co-routines. Co-routines are analogous to generators in Javascript and Python and are very powerful for implementing non pre-emptive, collaborative multi-threading. The idea is to turn a function call inside out. They really are neat for creating very elegant patterns. I'm a big fan of unix pipes and co-routines can implement sources, sinks and filters in a very concise way. The following example is a little test driver I knocked up to simulate processing CICS CMF records with different types of filters for serializing to JSON, ZLIB compression etc.

io = require("io")
zlib = require("zlib")
json = require("cjson")
socket = require("socket")

-- ZLIB compression filter
function zip(prod)
  return coroutine.create(function ()
    local dstream = zlib.deflate(zlib.BEST_SPEED)
    while true do
      local status, value = coroutine.resume(prod)
      if not status then break end
      coroutine.yield(dstream(value, "full"))
    end
  end)
end

-- filter to serialize a lua table to a JSON string
function jsonify(prod)
  return coroutine.create(function ()
    while true do
      local status, value = coroutine.resume(prod)
      if not status or not value then break end
      coroutine.yield(json.encode(value) .. "\n")
    end
  end)
end

-- filter to translate EBCDIC to ASCII
function e2a(prod)
  return coroutine.create(function ()
    while true do
      local status, value = coroutine.resume(prod)
      if not status or not value then break end
      coroutine.yield(os.e2a(value))
    end
  end)
end

-- file sink - defaults to QSAM but could take parameters
function file_sink(prod)
  local o, msg = io.open("SMF.OUTPUT", "wb, type=record, noseek")
  if not o then
    print(msg)
    os.exit(8)
  end
  while true do
    local status, rec = coroutine.resume(prod)
    if not status or not rec then break end
    print(rec)
    o:write(rec)
  end
end

-- socket sink to send stuff over the wire
function socket_sink(prod)
  local host = "172.17.70.3"
  local port = 6870
  local c = socket.connect(host, port)
  while true do
    local status, rec = coroutine.resume(prod)
    if not status or not rec then break end
    c:send(rec)
  end
end

-- simulate reading an SMF file
function file_source()
  return coroutine.create(function ()
    for n = 1, 1500 do
      local smfrec = {}
      smfrec.type = 110 -- CMF record
      smfrec.applid = "CICSWARE"
      smfrec.sysid = "MVS1"
      coroutine.yield(smfrec)
    end
  end)
end

-- main
file_sink(zip(jsonify(file_source())))
file_sink(zip(file_source()))
file_sink(jsonify(file_source()))
socket_sink(e2a(jsonify(file_source())))
socket_sink(zip(e2a(jsonify(file_source()))))

Lua is very fast. I've profiled it extensively using IBM Application Performance Analyzer and the interpreter overhead is < 10%. The majority of the time is spent in fast C library code.



Oh course, I do the same. But I do it to save on z/OS MSUs.
  On Jul 21, 2013 2:40 AM, "Shane Ginnane" <[email protected]> wrote:

On Sat, 20 Jul 2013 22:48:00 -0700, Lizette Koehler wrote:

If you go to CBTTAPE.ORG and go for FILE206, it seems to have a REXX
parser
for DCOLLECT records
Some (not too many) years ago I "lifted" a cbt offering to mangle dcollect
records - needed some mods for what I wanted, but did the job admirably.
Not sure if this was it, but as always, the cbt has things you can use - or
use as templates at least.
Maybe If I was doing it today I'd flick the file to zLinux and use tools
more applicable to this century than Rexx.

Shane ...

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to