Text processing/Max licenses in use: Difference between revisions

m (→‎{{header|Sidef}}: removed the useless "line.chomp")
Line 1,644:
2008/10/03_08:39:34 through 2008/10/03_08:39:45,
2008/10/03_08:40:40 through 2008/10/03_08:40:47
</pre>
 
=={{header|Phix}}==
Modified copy of [[Max_licenses_in_use#Euphoria|Euphoria]]
<lang Phix>constant fn = open("mlijobs.txt", "r")
integer maxout = 0, jobnumber
sequence jobs = {}, maxtime, scanres
string inout, jobtime
object line
while 1 do
line = gets(fn)
if atom(line) then exit end if
scanres = scanf(line,"License %s @ %s for job %d\n")
if length(scanres)!=1 then
printf(1,"error scanning line: %s\n",{line})
{} = wait_key()
abort(0)
end if
{{inout,jobtime,jobnumber}} = scanres
if inout="OUT" then
jobs &= jobnumber
if length(jobs)>maxout then
maxout = length(jobs)
maxtime = {jobtime}
elsif length(jobs)=maxout then
maxtime = append(maxtime, jobtime)
end if
else
jobs[find(jobnumber,jobs)] = jobs[$]
jobs = jobs[1..$-1]
end if
end while
close(fn)
printf(1, "Maximum simultaneous license use is %d at the following times:\n", maxout)
for i = 1 to length(maxtime) do
printf(1, "%s\n", {maxtime[i]})
end for</lang>
{{out}}
<pre>
Maximum simultaneous license use is 99 at the following times:
2008/10/03_08:39:34
2008/10/03_08:40:40
</pre>
 
7,822

edits