Sign in Join
FPDoc Onlineexperiment

IsValidIdent function

In unit sysutils

Check whether a string is a valid identifier name.

Declaration

pascal
function IsValidIdent(const Ident: string; AllowDots: Boolean=False; 
 StrictDots: Boolean=False): Boolean

Description

IsValidIdent returns True if Ident can be used as a component name. It returns False otherwise. Ident must consist of a letter or underscore, followed by a combination of letters, numbers or underscores to be a valid identifier.

Errors

None.

Example: ex75

pascal
Program Example75;

{ This program demonstrates the IsValidIdent function }

Uses sysutils;

Procedure Testit (S : String);

begin
  Write ('"',S,'" is ');
  If not IsVAlidIdent(S) then
    Write('NOT ');
  Writeln ('a valid identifier');
end;

Begin
  Testit ('_MyObj');
  Testit ('My__Obj1');
  Testit ('My_1_Obj');
  Testit ('1MyObject');
  Testit ('My@Object');
  Testit ('M123');
End.

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.