DMDScript - How to read a redirected file [stdin] until EOF ?
- Anthony Borla (39/39) Oct 30 2005 Greetings,
Greetings,
I'd like to read into a DMDScript script data from a file that has been
redirected as input from the command-line. For example, if I enter the
following command:
ds myscript.ds < myfile.txt
I would like the contents of 'myfile.txt' available to the script.
Importantly, too, it should be possible to accept 'empty' lines [i.e. lines
consisting solely of the end-of-line terminator] without terminating the
reading process.
I am able to accomplish this task via the Windows Scripting Host using the
following code:
var fStream = WScript.StdIn;
var buffer;
while (!fStream.AtEndOfStream)
{
buffer = fStream.ReadLine();
WScript.Echo(buffer);
}
I understand that the nearest analog to such functionality in DMDScript is
the 'readln' function, and that the DMDScript equivalent to above code is
something like:
var buffer = readln();
while (buffer.length > 0)
{
println(buffer);
buffer = readln();
}
This code works as long as no 'empty' lines are encountered; it is thus not
possible to read in a textfile containing such lines, something I would
class as more than a mere annoyance.
My question in this case, are:
* Have I perhaps missed someting in my use of 'readln'
and that it is actually able to read 'empty' lines without
terminating ?
* If not, then are there any plans for this situation to be
remedied in a future release of DMDScript ?
I look forward to any response.
Cheers,
Anthony Borla
Oct 30 2005








"Anthony Borla" <ajborla bigpond.com>