2016-10-20 16:07:28 +00:00
|
|
|
# example program: reading a URL over HTTP
|
|
|
|
|
2016-10-20 07:24:16 +00:00
|
|
|
def main [
|
|
|
|
local-scope
|
2016-10-23 21:25:13 +00:00
|
|
|
google:&:source:char <- start-reading-from-network 0/real-resources, [google.com/]
|
2016-10-20 07:24:16 +00:00
|
|
|
n:num <- copy 0
|
2016-10-20 22:04:01 +00:00
|
|
|
buf:&:buffer <- new-buffer 30
|
2016-10-20 07:24:16 +00:00
|
|
|
{
|
|
|
|
c:char, done?:bool <- read google
|
|
|
|
break-if done?
|
|
|
|
n <- add n, 1
|
2016-10-20 22:04:01 +00:00
|
|
|
buf <- append buf, c
|
2016-10-20 07:24:16 +00:00
|
|
|
loop
|
|
|
|
}
|
2016-10-20 22:04:01 +00:00
|
|
|
result:text <- buffer-to-array buf
|
2016-10-20 07:24:16 +00:00
|
|
|
open-console
|
|
|
|
len:num <- length *result
|
|
|
|
print 0/real-screen, result
|
|
|
|
wait-for-some-interaction
|
|
|
|
close-console
|
|
|
|
]
|