1 # example program: reading a URL over HTTP
 2 
 3 def main [
 4   local-scope
 5   $print [aaa] 10/newline
 6   google:&:source:char <- start-reading-from-network 0/real-resources, [google.com/]
 7   $print [bbb] 10/newline
 8   n:num <- copy 0
 9   buf:&:buffer:char <- new-buffer 30
10   {
11     c:char, done?:bool <- read google
12     break-if done?
13     n <- add n, 1
14     buf <- append buf, c
15     {
16       _, a:num <- divide-with-remainder n, 100
17       break-if a
18       $print n 10/newline
19     }
20     loop
21   }
22   result:text <- buffer-to-array buf
23   open-console
24   clear-screen 0/screen  # non-scrolling app
25   len:num <- length *result
26   print 0/real-screen, result
27   wait-for-some-interaction
28   close-console
29 ]