[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: VMs: entropy program
19/08/2003 12:42:45 AM, "Rafal T. Prinke" <rafalp@xxxxxxxxxx> wrote:
>So it seems that Monkey filters EOL off (I used "Space ON")
>while JEC counts it as two different characters CR and LF
>(it doesn't say that, but it is pretty obvious).
It reads and stores the sample text as a 1-dimensional
array of characters, with the filters set by the user.
An EOL is not ignored, it is replaced by a space
(with "Space OFF" it is ignored)
>I have now removed all EOL chars and spaces from my "random
>text" and the results from both programs where closer.
>But this time Monkey read only 255 characters of the 4,888
>(why?).
Because MONKEY is written in Turbo Pascal and uses the
readln procedure to read the sample text, line by line,
storing each as a string, before it loads it into the
"text array". A Pascal string is composed of a length
byte followed by the string itself. So Pascal strings
are limited to 255 characters. If you remove all EOLs
then you have a single line. The Pascal readln reads
it but it can store only the first 255 characters.
Instead, leave your "random text" as it is, and use
"Spaces OFF". The text will be read line by line,
and the spaces and EOLs discarded, which is what you
want.
Technical note: the Pascal readln procedure returns
the line up to the EOL character(s) _exclusively_.
The language I am currently using has gets() for this,
which returns the line with the EOL character appended
(not _characters_: it replaces the DOS #13#10
sequence with a single character). It is all
somewhat confusing, on first acquaintance.
______________________________________________________________________
To unsubscribe, send mail to majordomo@xxxxxxxxxxx with a body saying:
unsubscribe vms-list