"เฮลโลเวิลด์",
"حريات وحقوق",
"תוכנית"];
-str_exec = 'disp(''OK'');';
-for i = 1 : size(tab_ref,'*')
- mkdir(TMPDIR + filesep() + tab_ref(i));
- fd = mopen(TMPDIR + filesep() + tab_ref(i) + filesep() + tab_ref(i) + '.sce','wt');
- mputl(str_exec,fd);
- mclose(fd);
- exec(TMPDIR + filesep() + tab_ref(i) + filesep() + tab_ref(i) + '.sce');
- mdelete(TMPDIR + filesep() + tab_ref(i) + filesep() + tab_ref(i) + '.sce');
- rmdir(TMPDIR + filesep() + tab_ref(i));
-end
-
- OK
-
- OK
-
- OK
-
- OK
-
- OK
-
- OK
+str_exec = "disp(''OK'');";
+for i = 1 : size(tab_ref,"*")
+ mkdir(TMPDIR + filesep() + tab_ref(i));
+ fd = mopen(TMPDIR + filesep() + tab_ref(i) + filesep() + tab_ref(i) + ".sce","wt");
+ mputl(str_exec,fd);
+ mclose(fd);
+ exec(TMPDIR + filesep() + tab_ref(i) + filesep() + tab_ref(i) + ".sce");
+ mdelete(TMPDIR + filesep() + tab_ref(i) + filesep() + tab_ref(i) + ".sce");
+ rmdir(TMPDIR + filesep() + tab_ref(i));
+end
+ OK
+ OK
+ OK
+ OK
+ OK
+ OK
// create a script file
-mputl('a=1;b=2',TMPDIR+'/myscript')
- ans =
-
- T
+mputl("a=1;b=2",TMPDIR+"/myscript");
// execute it
-exec(TMPDIR+'/myscript')
-
+exec(TMPDIR+"/myscript")
a=1;b=2
- b =
-
- 2.
-
-if isdef('a')<> %t then bugmes();quit;end
-if isdef('b')<> %t then bugmes();quit;end
-if a <> 1 then bugmes();quit;end
-if b <> 2 then bugmes();quit;end
+b =
+ 2.
+if isdef("a")<> %t then bugmes();quit;end
+if isdef("b")<> %t then bugmes();quit;end
+assert_checkequal(a, 1);
+assert_checkequal(b, 2);
// create a function
-deff('y=foo(x)','a=x+1;y=a^2');
+deff("y=foo(x)","a=x+1;y=a^2");
clear a b
// call the function
k = foo(1);
-if isdef('k')<> %t then bugmes();quit;end
-if isdef('a')<> %f then bugmes();quit;end
-if k <> 4 then bugmes();quit;end
-x=4; //create x to make it known by the script foo
+if isdef("k")<> %t then bugmes();quit;end
+if isdef("a")<> %f then bugmes();quit;end
+assert_checkequal(k, 4);
clear k y
-exec(foo);
- y =
-
- 25.
-if isdef('y')<> %t then bugmes();quit;end
-if y <> 25 then bugmes();quit;end
+// create a function and call this body as a script
+deff("script()","a=x+1;y=a^2");
+x=4; //create x to make it known by script
+exec(script);
+y =
+ 25.
+if isdef("y")<> %t then bugmes();quit;end
+if isdef("a")<> %t then bugmes();quit;end
+assert_checkequal(y, 25);