1. Re: Botmatch -Reply
Jay Turley wrote:
>I suggest that the API provide a file_write function that
>allows a bot to output a standard-format history sequence
on this note, for whomever is writing the API's,
i happened to have these 2 functions in my toolbox
already, so mebbe i can save y'all some typing...
they simply read and write any euphoria sequence
to or from disk...
constant
OPENREAD = "r",
OPENSAVE = "w",
OPENFAIL = -1
procedure Error(sequence message)
--what ever error routine you want here
--example:
if graphics_mode(-1) then end if
text_color(RED)
puts(1,"\n" & message & "\n")
text_color(WHITE) --reset dos to liveable
puts(1," ")
abort(1)
end procedure
function ReadSequence(sequence filename)
--reads a sequence, from a file named filename, and returns
--a valid euphoria sequence or subs out to the error function
--long filenames under a dos box can be supported but the
--filename would have to be something like:
--mydata =
-- ReadSequence("\"c:\program files\database\mydatabase.seq\"")
integer fn
object junk
fn = open(filename,OPENREAD)
if fn = OPENFAIL then
Error("ReadSequence:cannot open " & filename)
end if
junk = get(fn)
close(fn)
if junk[1] = GET_SUCCESS then return junk[2] end if
Error("ReadSequence of:" & filename & " failed.\n" &
"Improper sequence in file.")
end function
procedure SaveSequence(sequence filename,sequence data)
--saves any arbitrary euphoria sequence to a file...
--see notes under ReadSequence for longfilenames
--usage: SaveSequence("mydata.seq",mydata)
integer fn
fn = open(filename,OPENSAVE)
if fn = OPENFAIL then
Error("SaveSequence:cannot save " & filename)
end if
print(fn,data)
close(fn)
end procedure