Smart pascal source code
{
Special DWSII Syntax:
It's possible to declare variables everywhere in
the script code. The declaration is valid inside the
active block and its sub-blocks.
}
var x: Integer;
var s: Integer;
for x := 0 to 10 do
begin
var s: string; // overrides previous declaration
// of "s" (only inside this loop)
s := IntToStr(x);
WriteLn(s);
end;
for x := 0 to 10 do
begin
var s: Float; // overrides previous declaration
// of "s" (only inside this loop)
s := Sqrt(x);
WriteLn(FloatToStr(s, 3));
end;
for x := 0 to 10 do
begin
s := Round(Sqr(x)); // No redeclaration of "s" so
// the initial declaration is used
WriteLn(s);
end;
{<<< RESULT - CONSOLE LOG >>>
-----------------------------
Errors >>>>
Hint: Name "s" could be ambiguous in its scope context [line: 16, column: 7]
Hint: Name "s" could be ambiguous in its scope context [line: 24, column: 7]
Result >>>>
0
1
2
3
4
5
6
7
8
9
10
0.000
1.000
1.414
1.732
2.000
2.236
2.449
2.646
2.828
3.000
3.162
0
1
4
9
16
25
36
49
64
81
100
-----------------------------
{<<<<<<<<< THE END >>>>>>>>>}
function FloatToStr$_Float_(i) { return i.toString() }
function FloatToStr$_Float_Integer_(i,p) { return (p==99)?i.toString():i.toFixed(p) }
var x = 0;
var s = 0;
var s$1 = "";
var s$2 = 0;
/* <<< main JS >>> */
for(x=0;x<=10;x++) {
s$1 = x.toString();
WriteLn(s$1);
}
for(x=0;x<=10;x++) {
s$2 = Math.sqrt(x);
WriteLn(FloatToStr$_Float_Integer_(s$2,3));
}
for(x=0;x<=10;x++) {
s = Math.round((x*x));
WriteLn(s);
}