I have a subroutine in a script that generates a log file, and it is having some problems. I was reviewing a directory of logs, and I found one that was very strange. Half of the log is not written. Some programming languages put the data to be written in a buffer before writing it to the disk, and if the program crashs the data in the buffer can be lost. Here is an example with psuedo code.
It looks like this code should output three lines before crashing, but sometimes it crashes with that data still in the buffer. And the result is sometimes zero, one, two, or all three lines are displayed.
Can this sort of condition happen in vbscript? This is the piece of code that is causing problems. The last line that is being displayed in the log file is the script version. This works 95% of the time. Is this a buffer problem or an error in my code?
The answer is yes and no. The WSH does buffer the output, but if the engine dies unexpectedly, it does it's best to flush the buffer to the right place.