Pas2JS pascal source code
var
i: Integer;
b : Boolean;
s : String;
a : array[0..16] of String;
BEGIN
{ BOOLEAN TO STRING }
WriteLn(BoolToStr(b));
WriteLn(StrToBool(BoolToStr(b)));
b:=not b;
WriteLn(BoolToStr(b));
WriteLn(StrToBool(BoolToStr(b)));
a := ['y', 'Y', 'n', 'N',
'yes', 'Yes',
'no', 'No',
't', 'T', 'f', 'F',
'true', 'True',
'false', 'False',
'dummy'];
for s in a do begin
WriteLn(s);
WriteLn(' : ');
WriteLn(StrToBool(s));
end;
{ CONSOLE OUTPUTS
False
False
True
True
y : True
Y : True
n : False
N : False
yes : True
Yes : True
no : False
No : False
t : True
T : True
f : False
F : False
true : True
True : True
false : False
False : False
dummy : False
}
function StrToBool(s) { return (/^(t|y|1|true|yes)$/i).test(s) }
function BoolToStr(b) { return b?"True":"False" }
var i = 0;
var b = false;
var s = "";
var a = ["","","","","","","","","","","","","","","","",""],
a$1 = 0;
WriteLn(BoolToStr(b));
WriteLn(StrToBool(BoolToStr(b)));
b = !b;
WriteLn(BoolToStr(b));
WriteLn(StrToBool(BoolToStr(b)));
a = ["y", "Y", "n", "N", "yes", "Yes", "no", "No", "t", "T", "f", "F", "true", "True", "false", "False", "dummy"];
for(a$1=0;a$1<=16;a$1++) {
s = a[a$1];
WriteLn(s);
WriteLn(" : ");
WriteLn(StrToBool(s));
}