| 1 |
1--> #!/usr/bin/env regina |
| 2 |
1--> /* this program tests the behaviour of reaching EOF using LINEIN */ |
| 3 |
1--> |
| 4 |
1--> Parse Source os . fn |
| 5 |
1--> do while lines(fn) > 0 |
| 6 |
1--> say '1-->' linein(fn) |
| 7 |
1--> end |
| 8 |
1--> call stream fn, 'C', 'CLOSE' |
| 9 |
1--> |
| 10 |
1--> signal on notready name eof |
| 11 |
1--> do forever |
| 12 |
1--> say '2-->' linein(fn) |
| 13 |
1--> end |
| 14 |
1--> Say "Shouldn't get here!" |
| 15 |
1--> Return |
| 16 |
1--> eof: |
| 17 |
1--> say 'Got NOTREADY from' sigl 'This is correct!' |
| 18 |
1--> |
| 19 |
1--> file='eoftest.dat' |
| 20 |
1--> if os = 'UNIX' Then |
| 21 |
1--> call charout file,'a'|| '0a'x || '1a'x,1 |
| 22 |
1--> else |
| 23 |
1--> call charout file,'a'|| '0d0a'x || '1a'x,1 |
| 24 |
1--> call stream file, 'c', 'close' |
| 25 |
1--> call on notready name linein_err |
| 26 |
1--> rc=0 |
| 27 |
1--> do while rc=0 |
| 28 |
1--> say c2x(linein(file)) |
| 29 |
1--> end |
| 30 |
1--> say 'Should get here! Returning...' |
| 31 |
1--> return |
| 32 |
1--> linein_err: |
| 33 |
1--> say 'got NOTREADY from line' sigl 'This is correct!' |
| 34 |
1--> rc=1 |
| 35 |
1--> return |
| 36 |
1--> /* last line */ |
| 37 |
2--> #!/usr/bin/env regina |
| 38 |
2--> /* this program tests the behaviour of reaching EOF using LINEIN */ |
| 39 |
2--> |
| 40 |
2--> Parse Source os . fn |
| 41 |
2--> do while lines(fn) > 0 |
| 42 |
2--> say '1-->' linein(fn) |
| 43 |
2--> end |
| 44 |
2--> call stream fn, 'C', 'CLOSE' |
| 45 |
2--> |
| 46 |
2--> signal on notready name eof |
| 47 |
2--> do forever |
| 48 |
2--> say '2-->' linein(fn) |
| 49 |
2--> end |
| 50 |
2--> Say "Shouldn't get here!" |
| 51 |
2--> Return |
| 52 |
2--> eof: |
| 53 |
2--> say 'Got NOTREADY from' sigl 'This is correct!' |
| 54 |
2--> |
| 55 |
2--> file='eoftest.dat' |
| 56 |
2--> if os = 'UNIX' Then |
| 57 |
2--> call charout file,'a'|| '0a'x || '1a'x,1 |
| 58 |
2--> else |
| 59 |
2--> call charout file,'a'|| '0d0a'x || '1a'x,1 |
| 60 |
2--> call stream file, 'c', 'close' |
| 61 |
2--> call on notready name linein_err |
| 62 |
2--> rc=0 |
| 63 |
2--> do while rc=0 |
| 64 |
2--> say c2x(linein(file)) |
| 65 |
2--> end |
| 66 |
2--> say 'Should get here! Returning...' |
| 67 |
2--> return |
| 68 |
2--> linein_err: |
| 69 |
2--> say 'got NOTREADY from line' sigl 'This is correct!' |
| 70 |
2--> rc=1 |
| 71 |
2--> return |
| 72 |
2--> /* last line */ |
| 73 |
Got NOTREADY from 12 This is correct! |
| 74 |
61 |
| 75 |
1A |
| 76 |
|
| 77 |
got NOTREADY from line 28 This is correct! |
| 78 |
Should get here! Returning... |