-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathautoreadtick.d
53 lines (46 loc) · 1.13 KB
/
autoreadtick.d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
Arthur: Joel Ezra Christensen
Date: 26 Feb 2010
*/
//version = TickOver;
version = AutoRead;
import std.stdio: writeln, write, stdin;
import std.string: lines, stripr, toStringz, split, replace;
import core.thread: Thread, dur;
alias dur!"msecs" linePause;
void main() {
version ( AutoRead ) {
string[] strLines;
// Main string holds all the data at once
auto content = lines( stdin );
foreach ( string line; content ) { // Read in text line by line (to choose text put in the command prompt eg. 'textscoll < journal.txt'
strLines ~= stripr( line );
}
// Go round and round
for( int i = 0; ; ) {
writeln( strLines[ i ] );
Thread.sleep( linePause ( 100 ) );
if ( i + 1 == strLines.length )
i = 0;
else
++i;
}
}
version ( TickOver ) {
int msecs,
seconds;
foreach( p; 0 .. 10 ) {
if ( p < 5 ) {
writeln( msecs, ") msecs" );
Thread.sleep( dur!"msecs"( 10 ) );
++msecs;
}
else {
writeln( seconds, ") seconds" );
if ( p < 9 )
Thread.sleep( dur!"seconds"( 1 ) );
++seconds;
}
}
}
}