annotate samples/file.tp @ 297:abe3141caefe

Added file module and sample
author Michael Pavone <pavone@retrodev.com>
date Thu, 24 Jul 2014 23:53:54 -0700
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
297
abe3141caefe Added file module and sample
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
1 #{
abe3141caefe Added file module and sample
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
2 import: [
abe3141caefe Added file module and sample
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
3 stdin
abe3141caefe Added file module and sample
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
4 stdout
abe3141caefe Added file module and sample
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
5 ] from: file
abe3141caefe Added file module and sample
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
6 main <- {
abe3141caefe Added file module and sample
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
7 stdout write: "Hello from the file module!\nWhat's your name?\n"
abe3141caefe Added file module and sample
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
8 name <- (stdin nextLine) trim
abe3141caefe Added file module and sample
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
9 stdout write: "Nice to meet you " . name . ". Here's my source code:\n\n"
abe3141caefe Added file module and sample
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
10 f <- file open: "samples/file.tp"
abe3141caefe Added file module and sample
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
11 foreach: (f lines) :num text {
abe3141caefe Added file module and sample
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
12 print: (string: num+1) . ": " . text
abe3141caefe Added file module and sample
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
13 }
abe3141caefe Added file module and sample
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
14 print: "\n"
abe3141caefe Added file module and sample
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
15 f close
abe3141caefe Added file module and sample
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
16 0
abe3141caefe Added file module and sample
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
17 }
abe3141caefe Added file module and sample
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
18 }