Another update from ingydotnet^djgoku

This commit is contained in:
Ingy döt Net 2015-11-18 06:14:39 +00:00
parent 91df62d461
commit 948b86eafa
7604 changed files with 108452 additions and 22726 deletions

View file

@ -0,0 +1,53 @@
class
APPLICATION
create
make
feature
make
-- Max Licences used.
local
count: INTEGER
max_count: INTEGER
date: STRING
do
read_list
create date.make_empty
across
data as d
loop
if d.item.has_substring ("OUT") then
count := count + 1
if count > max_count then
max_count := count
date := d.item
end
elseif d.item.has_substring ("IN") then
count := count - 1
end
end
io.put_string ("Max Licences OUT: " + max_count.out)
io.new_line
io.put_string ("Date: " + date.substring (15, 33))
end
original_list: STRING = "mlijobs.txt"
feature {NONE}
read_list
-- Data read into 'data.
local
l_file: PLAIN_TEXT_FILE
do
create l_file.make_open_read_write (original_list)
l_file.read_stream (l_file.count)
data := l_file.last_string.split ('%N')
l_file.close
end
data: LIST [STRING]
end

View file

@ -1,88 +1,20 @@
/*REXX program to process instrument data from a data file. */
/*REXX program processes instrument data as read from a time sorted data file.*/
iFID= 'LICENSE.LOG' /*the fileID of the input file. */
high=0 /*highest number of licenses (so far). */
#=0 /*the count of number of licenses out. */
n=0 /*the number of highest licenses out. */
do recs=0 while lines(iFID)\==0 /* [↓] read file until end─of─file. */
parse value linein(iFID) with . ? . $ /*get IN│OUT status, job info.*/
if ?=='IN' then #=#-1 /*decrement the license count.*/
else if ?=='OUT' then #=#+1 /*increment " " " */
if # >high then do; n=1; job.1=$; end /*the job info for highest cnt*/
if #==high then do; n=n+1; job.n=$; end /* " " " " equal " */
high=max(high,#) /*calculate max license count.*/
end /*while ···*/
numeric digits 20 /*allow for bigger numbers. */
ifid='LICENSE.LOG' /*the input file. */
ofid='LICENSE.REP' /*the report file. */
monthDays.=31 /*number of days in every month. */
monthDays.4 =30
monthDays.6 =30
monthDays.9 =30
monthDays.11=30
otime='9999 99 99 99 99 99' /*latest OUT time. */
itime='0000 00 00 00 00 00' /*latest IN time. */
lowjob=99999
highjob=0
do while lines(ifid)\==0 /*read until finished. */
rec=linein(ifid) /*read the next record (line). */
parse upper var rec . InOut . datestamp . . job# /*get some stuff*/
$datestamp=translate(datestamp,,'/:_')
if InOut=='IN' then do
in.job#=$datestamp /*<─────assign an IN record.*/
if $datestamp>Itime then itime=$datestamp
end
else do
out.job#=$datestamp /*<─────assign an OUT record.*/
if $datestamp<otime then otime=$datestamp
end
lowjob=min( lowjob,job#)
highjob=max(highjob,job#)
end /*DO WHILE*/
has=0
maxhas=0
qtime=otime
mtimeL=''
do jjj=1 until qtime>itime
has=inRange(qtime)
if has==maxhas then mtimeL=qtime
if has>maxhas then do
maxhas=has
mtime=qtime
mtimes=qtime
end
qtime=addAsec(qtime)
end /*DO UNTIL*/
call sy
parse var mtimes yy mm dd hh mn ss; _=yy'/'mm"/"dd hh':'mn":"ss
call sy 'maximum number of licenses out is ' maxhas " at " _
if mtimeL\=='' & mtimeL\==mtimes then
do
maxhas__=left('',length(maxhas)+5)
parse var mtimeL yy mm dd hh mn ss; _=yy'/'mm"/"dd hh':'mn":"ss
call sy ' through ' maxhas__ _
end
exit
/*─────────────────────────────────────addAsec subroutine───────────────*/
addAsec: procedure expose monthDays.; parse arg yy mm dd hh mn ss
ss=right(ss+1 ,2,0) ; if ss<60 then return yy mm dd hh mn ss
ss=right(ss-60,2,0); mn=right(mn+1,2,0); if mn<60 then return yy mm dd hh mn ss
mn=right(mn-60,2,0); hh=right(hh+1,2,0); if hh<24 then return yy mm dd hh mn ss
monthDays.2=28+leapyear(yy)
??=monthDays.mm
hh=right(hh-24,2,0); dd=right(dd+1,2,0); if dd<?? then return yy mm dd hh mn ss
mm=right(mm-??,2,0); yy=right(yy+y,4,0)
return yy mm dd hh mn ss
/*─────────────────────────────────────inRange subroutine───────────────*/
inRange: hases=0; parse arg xtime /*see if xtime is in jobs' range.*/
do j=lowjob to highjob
if xtime << out.j then leave
if xtime >> in.j then iterate
hases=hases+1
end
return hases
/*─────────────────────────────────────LEAPYEAR subroutine──────────────*/
leapyear: procedure; arg y /*year could be: Y, YY, YYY, YYYY*/
if length(y)==2 then y=left(right(date(),4),2)y /*adjust for YY year.*/
if y//4\==0 then return 0 /* not ≈ by 4? Not a leapyear.*/
return y//100\==0 | y//400==0 /*apply 100 and 400 year rule. */
/*─────────────────────────────────────SY subroutine────────────────────*/
sy: procedure expose ofid; say arg(1); call lineout ofid,arg(1); return
say recs 'records read from the input file: ' iFID
say 'The maximum number of licenses out is ' high " at:"
say
do j=1 for n /*show what/when max licenses occurred.*/
say left('',20) job.j /*indent the information displayed. */
end /*j*/ /*stick a fork in it, we're all done. */

View file

@ -1,11 +1,13 @@
/* REXX **************************************************************
* 19.11.2012 Walter Pachl transscribed from PL/I
* 19.11.2012 Walter Pachl transcribed from PL/I
* and dual-coded (for PC (Windows) and TSO)
**********************************************************************/
Parse Source source
call time 'R'
Say source
If left(source,7)='Windows' Then Do
Parse Upper source system .
If left(system,3)='WIN' |, /* changed from 'Windows' (I see WIN64 in source) */
wordpos(system,'MSDOS PCDOS')>0 Then Do
fid='mlijobs.txt'
Do i=1 By 1 While lines(fid)>0
l.i=linein(fid)