sumim #7002(2008/08/06 05:21 GMT) [ Smalltalk ] Rating0/0=0.00
Squeak Smalltalk で、それっぽい動きをするものを。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| filename file numOfLines isFollowMode lineCount savedPosition | filename := 'in.txt'. numOfLines := 10. isFollowMode := false. file := FileStream fileNamed: filename. file setToEnd. file binary. lineCount := 0. [file position > 0 and: [lineCount < numOfLines]] whileTrue: [file back = 13 ifTrue: [lineCount := lineCount + 1]]. file ascii. World findATranscript: nil. Transcript cr; show: file upToEnd. savedPosition := file position. file close. isFollowMode ifTrue: [ [Sensor keyboardPressed] whileFalse: [ (Delay forSeconds: 5) wait. file reopen; position: savedPosition. Transcript show: file upToEnd. savedPosition := file position. file close]]
Rating0/0=0.00-0+
[ reply ]
sumim
#7002()
[
Smalltalk
]
Rating0/0=0.00
Squeak Smalltalk で、それっぽい動きをするものを。
| filename file numOfLines isFollowMode lineCount savedPosition | filename := 'in.txt'. numOfLines := 10. isFollowMode := false. file := FileStream fileNamed: filename. file setToEnd. file binary. lineCount := 0. [file position > 0 and: [lineCount < numOfLines]] whileTrue: [file back = 13 ifTrue: [lineCount := lineCount + 1]]. file ascii. World findATranscript: nil. Transcript cr; show: file upToEnd. savedPosition := file position. file close. isFollowMode ifTrue: [ [Sensor keyboardPressed] whileFalse: [ (Delay forSeconds: 5) wait. file reopen; position: savedPosition. Transcript show: file upToEnd. savedPosition := file position. file close]]Rating0/0=0.00-0+
[ reply ]