#!/usr/local/bin/rexx
/* --- initialise variables --- */
filename = "events"
homedir = "/home/web/home/tof_forms/"
txt_file = homedir || filename || ".txt"
/* -------------- CHANGE -------------------- */
html_file = homedir || filename || ".html"
link_file = filename || ".html"
call load_events
call BubbleSort
call WriteFile
exit
/* ---------------- Load events from file ------------- */
load_events:
f = open(txt_file,"r")
if f<0 then do
title.0 = 0
return
end
n = 0
do until eof(f)
n = n + 1
title.n = linein(f)
url.n = linein(f)
by.n = linein(f)
type.n = linein(f)
place.n = linein(f)
fday.n = linein(f)
fmonth.n = linein(f)
fyear.n = linein(f)
uday.n = linein(f)
umonth.n = linein(f)
uyear.n = linein(f)
institute.n = linein(f)
organisers.n = linein(f)
comments.n = linein(f)
end
call close f
title.0 = n-1
return
/* ----------------- BubbleSort ------------------- */
BubbleSort:
do i=2 to title.0
changed = 0
do j=title.0 to i by -1
jp = j-1
prev = fyear.jp"/"right(fmonth.jp,2,0)"/"right(fday.jp,2,0)
cur = fyear.j"/"right(fmonth.j,2,0)"/"right(fday.j,2,0)
if prev < cur then do
str = title.j
title.j = title.jp
title.jp = str
str = url.j
url.j = url.jp
url.jp = str
str = by.j
by.j = by.jp
by.jp = str
str = type.j
type.j = type.jp
type.jp = str
str = place.j
place.j = place.jp
place.jp = str
str = fday.j
fday.j = fday.jp
fday.jp = str
str = fmonth.j
fmonth.j = fmonth.jp
fmonth.jp = str
str = fyear.j
fyear.j = fyear.jp
fyear.jp = str
str = uday.j
uday.j = uday.jp
uday.jp = str
str = umonth.j
umonth.j = umonth.jp
umonth.jp = str
str = uyear.j
uyear.j = uyear.jp
uyear.jp = str
str = institute.j
institute.j = institute.jp
institute.jp = str
str = organisers.j
organisers.j = organisers.jp
organisers.jp = str
str = comments.j
comments.j = comments.jp
comments.jp = str
changed = 1
end
end
if ^changed then leave
end
return
/* --------------- WriteFile ----------------- */
WriteFile:
f = open(html_file,"w")
if f<0 then do
say "Error creating file '"html_file"'!.
"
say "Please contact administrator.
"
return
end
call lineout f, ''
call lineout f, '
' call lineout f, '' call lineout f, '' call lineout f, '' call lineout f, ' | ' call lineout f, ''
call lineout f, '
|
' call lineout f, '
' call lineout f,'
'fyear.i' | ' call lineout f,'
' call lineout f,'
' call lineout f, '
Automatically created by'
call lineout f, 'Vivian Synteta''s BRexx script'
call lineout f, ' ' call lineout f, 'Last updated 'date()' | '
call lineout f, 'TOF Home Page ' call lineout f, ' | ' call lineout f, '