diff options
author | Kartik Agaram <vc@akkartik.com> | 2019-07-27 16:01:55 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2019-07-27 17:47:59 -0700 |
commit | 6e1eeeebfb453fa7c871869c19375ce60fbd7413 (patch) | |
tree | 539c4a3fdf1756ae79770d5c4aaf6366f1d1525e /archive/2.vm/http-client.mu | |
parent | 8846a7f85cc04b77b2fe8a67b6d317723437b00c (diff) | |
download | mu-6e1eeeebfb453fa7c871869c19375ce60fbd7413.tar.gz |
5485 - promote SubX to top-level
Diffstat (limited to 'archive/2.vm/http-client.mu')
-rw-r--r-- | archive/2.vm/http-client.mu | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/archive/2.vm/http-client.mu b/archive/2.vm/http-client.mu new file mode 100644 index 00000000..8f04c2bc --- /dev/null +++ b/archive/2.vm/http-client.mu @@ -0,0 +1,29 @@ +# example program: reading a URL over HTTP + +def main [ + local-scope + $print [aaa] 10/newline + google:&:source:char <- start-reading-from-network null/real-resources, [google.com/] + $print [bbb] 10/newline + n:num <- copy 0 + buf:&:buffer:char <- new-buffer 30 + { + c:char, done?:bool <- read google + break-if done? + n <- add n, 1 + buf <- append buf, c + { + _, a:num <- divide-with-remainder n, 100 + break-if a + $print n 10/newline + } + loop + } + result:text <- buffer-to-array buf + open-console + clear-screen null/screen # non-scrolling app + len:num <- length *result + print null/real-screen, result + wait-for-some-interaction + close-console +] |