When I said that Racter made a valid MS-DOS system call and it was one I was expecting [1], that didn't mean I was exactly happy Racter was using that particular MS-DOS (Microsoft Disk Operating System) [2] system call. In fact, it was one of the worst system calls [3] it could make, given what I'm trying to do.
Racter is calling the “direct console I/O” system call of MS-DOS. This system call is a very old system call and comes from CP/M (Control Program for Microcomputers) [4]. It's a system call that expects to send data to, and receive data from, an interactive terminal. The call is used for both input and output. If there's no input pending, it returns a “no data pending” status. This wreaks havoc because Eliza [5] isn't a user sitting at a terminal but another program.
Worse, the Racter executable is a compiled BASIC program (given away by the string “Microsoft BASIC Compiler Runtime” buried deep inside the executable) so it's expecting an interactive terminal (which is why it's using that particular system call).
I eventually got it working but it's a horrible hack. I set an “input flag” to false. This means when the “direct console I/O” is called looking for input, it returns “no data yet.” It's only when I see the characters for a carriage return, a line feed, and a “>” being written (which indicates Racter is now expecting input) do I switch the “input flag” to true. It stays true until it sees a carriage return as input (which indicates the user has finished typing their input) and then sets the flag to false. It's gross, but it works, and more importantly, it works when you pipe input from a file or from another process.
The other system calls Racter uses were fairly straightforward to implement with only one slight hiccup (the documented behavior of two calls caused Racter to exit; it was only when I added a feature that the two functions said was not done did it work—go figure Microsoft using undocumented behavior [6]). With only ten system calls used (out of a possible 41 for MS-DOS 1.0) it wasn't that bad.
So now I can connect Racter up with Eliza and let the two talk.
But having gotten this far, I'm not sure if I should even continue. I mean, yeah, I can hook the two up and spend a minute or two spewing out 50,000 words of conversation between the two, but … eh. I mean, yeah, there are some gems that pop out, such as “Sean, how are dogs like children? Their sanity and lunacy are instantly scary,” but even over an extended time, it gets weary.
I thought maybe having Racter conversing with itself might be fun, but alas, the random number generator [7] in Racter is exceedingly deterministic to the point where the output from each was identical and thus, not really worth having two of them converse.
Then again, I haven't even read much past the first page of The Quantum Supposition Of Oz [8] so perhaps I should just have Racter and Eliza duke it out, put it to bed, and think of another idea for next year.
[2] https://en.wikipedia.org/wiki/MS-DOS
[3] https://en.wikipedia.org/wiki/System_call
[4] https://en.wikipedia.org/wiki/CP/M
[5] http://psych.fullerton.edu/mbirnbaum/psych101/Eliza.htm
[6] http://fringe.davesource.com/Fringe/NonZen_Companies/Microsoft/FAQ/microfaq2.html
[7] https://en.wikipedia.org/wiki/Random_number_generation
[8] https://github.com/spc476/NaNoGenMo-2014/blob/master/TheQuantumSuppositionOfOz.txt