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
|
2017-12-04 07:25:40 +00:00
|
|
|
$print [aaa] 10/newline
|
2018-06-17 18:20:53 +00:00
|
|
|
google:&:source:char <- start-reading-from-network null/real-resources, [google.com/]
|
2017-12-04 07:25:40 +00:00
|
|
|
$print [bbb] 10/newline
|
2016-10-20 07:24:16 +00:00
|
|
|
n:num <- copy 0
|
2017-04-18 22:44:31 +00:00
|
|
|
buf:&:buffer:char <- 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
|
2017-12-04 07:25:40 +00:00
|
|
|
{
|
|
|
|
_, a:num <- divide-with-remainder n, 100
|
|
|
|
break-if a
|
|
|
|
$print n 10/newline
|
|
|
|
}
|
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
|
2018-06-17 18:20:53 +00:00
|
|
|
clear-screen null/screen # non-scrolling app
|
2016-10-20 07:24:16 +00:00
|
|
|
len:num <- length *result
|
2018-06-17 18:20:53 +00:00
|
|
|
print null/real-screen, result
|
2016-10-20 07:24:16 +00:00
|
|
|
wait-for-some-interaction
|
|
|
|
close-console
|
|
|
|
]
|