(* This program makes use of the '97 Library for SML. Hence run it using, eg, smlnj. *) fun semclub speaker jointwork dd Mmm yyyy title abstract url = (* semclub asks 8 strings as input. Examples: semclub "Albert Einstein" "Max Planck" "25" "Dec" "2000" "Relativity of Christmas" "abstract_of_talk" ""; semclub "Alex Simpson" "" "3" "Jul" "1998" "Computational adequacy" "abstract_of_talk" "als"; Note: Both the arguments jointwork and url can be "". The month has to be a three letters string as in Feb; the first letter should be upper case and the other two lower case. The input "url" can be given as simply the login name if the speaker has a web page at LFCS. Otherwise give the url of the speaker with or without "http://". Thus, for instance, both "dt", "http://www.dcs.ed.ac.uk/home/dt", and "www.dcs.ed.ac.uk/home/dt" will work. (If the speaker has no URL just give "" as input.) The argument abstract should be a plain text file. semclub produces five files, all named ddMmmyyyy but with five different extensions, namely .html, .mail, .reminder, .forthcoming, .recent. For instance: 25Dec2000.html, 25Dec2000.mail, 25Dec2000.reminder, 25Dec2000.forthcoming, 25Dec2000.recent. *) let val date = Mmm^" "^dd^", "^yyyy val dateFile = dd^Mmm^yyyy val jointworkSentence = if jointwork = "" then "" else " (joint work with "^jointwork^")" val name = if url = "" then speaker^"\n" else if size (url) > 8 (* login names at LFCS are not longer than 8 chars, hence, if the test is true then url cannot be just the login name *) then if substring (url, 0, 4) = "http" then ""^speaker^"" else ""^speaker^"" else (* otherwise it will be just the login name *) ""^speaker^"" val abstractStream = TextIO.openIn abstract and absMailStream = TextIO.openIn abstract (* two streams for the file abstract, as we need it both in the .html and in the .mail file *) and htmlFile = TextIO.openOut (dateFile ^ ".html") (* creates the file "date".html and links it to the stream htmlFile *) and mailFile = TextIO.openOut (dateFile ^ ".mail") and reminderFile = TextIO.openOut (dateFile ^ ".reminder") and forthcomingFile = TextIO.openOut (dateFile ^ ".forthcoming") and recentFile = TextIO.openOut (dateFile ^ ".recent") fun cvtAbs "" = () | cvtAbs "\n" = if TextIO.lookahead(abstractStream) = SOME #"\n" (* checks if also the next line is \n, in which case the insertion of
is delayed; this test is not really needed as multiple
's are the same as just one
, but it is a good example of how to use lookahead *) then cvtAbs (TextIO.inputLine abstractStream) else (TextIO.output (htmlFile, "
\n"); cvtAbs (TextIO.inputLine abstractStream)) | cvtAbs lineAbs = (TextIO.output (htmlFile, lineAbs); cvtAbs (TextIO.inputLine abstractStream)) in TextIO.output (htmlFile, (* the following is the second argument of TextIO.output and will produce the content (until the abstract) of the .html file after the execution of the command TextIO.output *) "\n"^ "\n"^ "
\n"^ "\n"^ jointworkSentence^"\n"^ "
\n" ); (* the following inserts the abstract with the proper paragraph spacing in the .html file *) cvtAbs (TextIO.inputLine abstractStream); (* the following command will produce the remaning of the .html file, ie the part folowing the abstract *) TextIO.output (htmlFile, "