Posts

Showing posts from January, 2016

Parameters in Delphi

Parameters Parameters are special kind of variables declared in a subroutine that are used to input some value into that subroutine. And the values that we pass in a function call is called as Arguments. in Delphi we can declare functions/procedures with parameters like following Example of a  Function declaration     function Add(Num1: integer; Num2: integer) : Integer; In above function declaration Num1, Num2 is called as Parameters. Using of function Add... var    iResult: integer; .......    iResult := Add(10, 20); 10, 20 are called as Arguments that are passed in function call. We can pass a single or multiple Parameter list to a Delphi subroutine. In case of Parameter list we declare Parameters separated by " ; " and enclosed by parenthesis. Parameter names must be valid identifiers. The parameter list specifies the number, order, and type of parameters that must be passed to the routine when it is called. Within the procedure or func

How to check for a valid EMail Address format in Delphi

Now a days most of applications have facility to send Email to Users with some information. So before send Email we generally check for valid Email address format. Here I have 2 approaches how to validate an Email address format in Delphi. 1. Validating Email addresses format using Regular Expression A regular expression is a special text that we can use as a search pattern. So for this we can use a regular expression string to check Email address syntax. And Delphi XE or later versions provide TRegEx class to use regular expression functions. So we can use this approach only on Delphi XE or latter versions. But f or this we have to use  System.RegularExpressions unit in Uses part.  ....     function IsMatch(const Input, Pattern: string): boolean;     function IsValidEmailRegEx(const EmailAddress: string): boolean; .... function TForm1.IsMatch(const Input, Pattern: string): boolean; begin   Result := TRegEx.IsMatch(Input, Pattern); end; function TForm1.I