Update loop_arg.b, add for_loop.b

master
Marvin Johanning 2020-05-29 07:51:58 +02:00
parent ac137ff14a
commit 3b20d4ca51
2 changed files with 24 additions and 4 deletions

15
for_loop.b Normal file
View File

@ -0,0 +1,15 @@
implement ForLoop;
include "sys.m";
include "draw.m";
sys: Sys;
ForLoop: module {
init: fn (ctxt: ref Draw->Context, args: list of string);
};
init (ctxt: ref Draw->Context, args: list of string) {
sys = load Sys Sys->PATH;
for (i := 0; i < 10; i++)
sys->print("%d", i);
}

View File

@ -5,13 +5,18 @@ include "draw.m";
sys: Sys;
GreetEvenMoreImproved: module {
init: fn (ctxt: ref Draw->Context, argv: list of string);
init: fn (ctxt: ref Draw->Context, args: list of string);
};
init(ctxt: ref Draw->Context, args: list of string) {
sys = load Sys Sys->PATH;
args = tl args;
args = tl args;
for (s := ""; args != nil; args = tl args)
s += " " + hd args;
if (s != "")
sys->print("%s\n", s[1:]);
if (s != "")
sys->print("Hello %s \n", s[1:]);
if (s == "")
sys->print("Enter your name.\n");
}