FloStringToBool
FloStringToBool converts a string value aValue, and checks against the parameter aTrueFalseStr, to ascertain whether aValue is a valid True or False string.
ATrueFalseStr is a list of the two (2) accepted responses, separated by a comma - the first representing True, the second representing False.
Neither parameter values are case sensitive.
The resulting response is a boolean value.
Please also refer to BooltoFloString for the opposite function.
Declaration: Function FloStringToBool(const aValue, aTrueFalseStr : string) : boolean
Several examples are detailed below.
procedure
OmMapEvent(
var
Value:Variant);
var
TheAnswer :
string
;
ConfYN:
boolean
;
begin
TheAnswer :=
'Y'
;
//Setting the variable to 'Y' (TRUE)
ConfYN := FloStringToBool(TheAnswer,
'Y,N'
);
//Is TheAnswer either 'Y' (True) or 'N' (False)?
If
ConfYN =
true
then
LogInfo(
'Yes its TRUE'
)
//ConfYN = True ('Y' equals the TRUE value 'Y')
else
LogInfo(
'No it is FALSE'
);
LogInfo(
''
);
TheAnswer :=
'N'
;
//Setting the variable to 'N' (FALSE)
ConfYN := FloStringToBool(TheAnswer,
'Y,N'
);
//Is TheAnswer either 'Y' (True) or 'N' (False)?
If
ConfYN =
true
then
LogInfo(
'Yes its TRUE'
)
else
LogInfo(
'No it is FALSE'
);
//ConfYN = False ('N' equals the FALSE value 'N')
LogInfo(
''
);
TheAnswer :=
'Yes'
;
//Setting the variable to 'Yes' (TRUE)
ConfYN := FloStringToBool(TheAnswer,
'Yes,No'
);
//Is TheAnswer either 'Yes' (True) or 'No' (False)?
If
ConfYN =
true
then
LogInfo(
'Yes its TRUE'
)
//ConfYN = True ('Yes' equals 'Yes')
else
LogInfo(
'No it is FALSE'
);
LogInfo(
''
);
TheAnswer :=
'y'
;
//Setting the variable to 'y' (TRUE)
ConfYN := FloStringToBool(TheAnswer,
'Yes,No'
);
//Is TheAnswer either 'Yes' (True) or 'No' (False)?
If
ConfYN =
true
then
LogInfo(
'Yes its TRUE'
)
else
LogInfo(
'No it is FALSE'
);
//ConfYN = False ('y' is not equal to 'Yes' or 'No')
LogInfo(
''
);
TheAnswer :=
'X'
;
//Setting the variable to 'X'
ConfYN := FloStringToBool(TheAnswer,
'Yes,No'
);
//Is TheAnswer either 'Yes' (True) or 'No' (False)?
If
ConfYN =
true
then
LogInfo(
'Yes its TRUE'
)
else
LogInfo(
'No it is FALSE'
);
//ConfYN = False ('X' is not equal to 'Yes' or 'No')
LogInfo(
''
);
TheAnswer :=
'TRUE'
;
//Setting the variable to 'TRUE'
ConfYN := FloStringToBool(TheAnswer,
'true,false'
);
//Is TheAnswer either 'true' or 'false'?
If
ConfYN =
true
then
LogInfo(
'Yes its TRUE'
)
//ConfYN = True (it equals 'true')
else
LogInfo(
'No it is FALSE'
);
LogInfo(
''
);
end
;