Update loop_arg.b, add for_loop.b
parent
ac137ff14a
commit
3b20d4ca51
|
@ -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);
|
||||
}
|
13
loop_arg.b
13
loop_arg.b
|
@ -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");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue