Skip to content

Flow documentation · legacy product

StringContainsOnly ​

Declaration ​

Function StringContainsOnly( const S : string; const aValid : TFloChars) : Boolean

Example ​

pascal
procedure BeforeMapEvent(var Value:Variant);
var
vDigits, vCurrSym: TFloChars;
vStr1, vStr2: string;
begin
vDigits := ['0','1','2','3','4','5','6','7','8','9'];
vCurrSym := ['$',',','.'];
vStr1 := '$123.00'; // digits and currency symbols only
vStr2 := 'NZD123.00'; // includes alpha characters

// test first string ... it should be OK
if StringContainsOnly(vStr1, vDigits + vCurrSym) then
LogInfo('String "' + vStr1 + '" contains only 0-9,$,.')
else
LogInfo('String "' + vStr1 + '" contains other than 0-9,$,.');

// test second string ... it should fail
if StringContainsOnly(vStr2, vDigits + vCurrSym) then
LogInfo('String "' + vStr2 + '" contains only 0-9,$,.')
else
LogInfo('String "' + vStr2 + '" contains other than 0-9,$,.');
end;

Description ​

Checks a string to see if it is made up of only the characters given by the set of characters in aValid. Useful to check that a string contains only what you want.

Sets of characters can be combined by using "+" as the Union operator.

(Note: Example replaced July 2014. Previous example was incorrect.)