Friday, October 12, 2007

How to work with FUNCTION

How to work with FUNCTION

To work with FUNCTION

Step 1

Description:

The function is a subprogram called form within an expression that returns a value through the function name.

Declaration:

function ident (parameters) : type;

Example:

function sumofsquares(n: integer): integer;

Edited By: Norasyikin Mahmud
© 2001 ISC
All rights reserved. All other product names and trademarks are registered properties of their respective owners.

051101

How to work with Boolean operators

How to work with Boolean operators

To work with Boolean operators

Step 1

Description:

Boolean operators are the special operators are use to combine Boolean expressions;

Declaration:

Operator Operation

not negation

and logical and

or logical or

xor logical xor

Example:

if (player1 > player2) or (player1 >= player2) then

Writeln(' The winner is player 1');

if (player1 <>

Writeln(' The winner is player 2');

How to work with relational operators

How to work with relational operators

To work with relational operators

Step 1

Description:

A sequence of identifiers, separated by compatible operators, that evaluates to TRUE or FALSE

Declaration:

Operator Operation

= Equal

Not equal

<>

Greater than

<= Less or equal

>= Greater or equal

Example:

if player1 > player2 then

Writeln(' The winner is player 1');

if player1 <>

Writeln(' The winner is player 2');

if player1 = player2 then

Writeln(' No winner in this game ');

How to work with Binary Arithmetic Operators

How to work with Binary Arithmetic Operators

To work with Binary Arithmetic Operators

Step 1

Description:

Arithmetic operators, which take real or integer operands, include +, –, *, /, div, and mod.

Declaration:

Operator Operation

+ Addition

Subtraction

Multiplication

/ Division

div Integer division

mod remainder

Example:

Writeln('Answer is : ',a+b+c);

Writeln('Answer is : ',a*b*c);

Writeln('Answer is : ',a+b-c);

How to work with CASE function

How to work with CASE function

To work with CASE function

Step 1

Description:

The case statement consists of an expression (the selector) and a list of statements, each prefixed with a case.

Declaration:

case expression of

case: statement;

...

case: statement;

end

Example:

case a of

'm': Writeln('You are the boy');

'f': Writeln('You are the girl');

end;

How to work REPEAT …. UNTIL statement

How to work REPEAT …. UNTIL statement

To work REPEAT …. UNTIL statement

Step 1

Description:

The statements between repeat and until are executed in sequence until, at the end of a sequence, the Boolean expression is True.

Declaration:

repeat

statement;

statement;

...

statement

until expression

Example:

Repeat

y:=(x*x*x+7*x-1)/(x*x-(x+5)/3);

Writeln;

Write(x,'',y);

if y>=0 then Write(' Admit ');

Writeln;

x:=x+0.50

Until x >=4.00;

How to work with FOR …. TO statements

How to work with FOR …. TO statements

To work with FOR …. TO statements

Step 1

Description:

The FOR statement is a looping construct designed specifically for count-controlled loops.

Declaration:

FOR variable identifier:= Expressionl TO Expression2 DO

Statement 1;

Statement 2;

Example:

for number:=4 to 9 do

begin

sqnumber:=number*number;

Writeln(number,' ',sqnumber)

End

How to work with WHILE statement

How to work with WHILE statement

To work with WHILE statement

Step 1

Description:

The while statements like the IF statements, tests a condition.

Declaration:

WHILE Boolean expression DO

Statements 1;

Statements 2;

Example:

While x <=4.00 do

begin

y:=(x*x*x+7*x-1)/(x*x-(x+5)/3);

Writeln;

Write(x,'',y);

if y>=0 then Write(' Admit ');

Writeln;

x:=x+0.50

end;

How to work with IF…….THEN……ELSE statement

How to work with IF…….THEN……ELSE statement

To work with IF…….THEN……ELSE statement

Step 1

Description:

The ability in make decisions.

Declaration:

IF Boolean expression

THEN

Statements 1

ELSE

Statements 2;

Statements;

Example:

if a > 10 Then

Writeln(' This integer is more then 10')

Else

Writeln(' This integer is small then 10');

How to work with IF…..THEN statement

How to work with IF…..THEN statement

To work with IF…..THEN statement

Step 1

Description:

The ability to make decisions.

Declaration:

IF Boolean expression

THEN

Statements 1;

Statements 2;

Example:

if a > 10 Then

Writeln(' This interger is more then 20');

How to work with record

How to work with record

To work with record

Step 1

Description:

The components of a record are called fields. Each field has its own field identifier and type

Example:

type

student=record

StudentNo:longint;

StudentName:string;

Department:string;

end;

How to work with array

How to work with array

To work with array

Step 1

Description:

Array is a structured group of like elements given a common name.

Declaration:

array [index-type] of element-type

Example:

var

mark:array [1..40] of integer;

How to work with real type

How to work with real type

To work with real type

Step 1

Description:

A real type defines a set of numbers that can be represented with floating-point notation.

Declaration:

Type Range

Real48 2.9 x 10^–39 .. 1.7 x 10^38

Single 1.5 x 10^–45 .. 3.4 x 10^38

Double 5.0 x 10^–324 .. 1.7 x 10^308

Extended 3.6 x 10^–4951 .. 1.1 x 10^4932

Comp –2^63+1 .. 2^63 –1

Currency –922337203685477.5808.. 922337203685477.5807

Example:

var

a:double;

b:single;

How to work with string

How to work with string

To work with string

Step 1

Description:

A string represents a sequence of characters.

Declaration:

Type Maximum length

ShortString 255 characters 2 to 256 bytes

AnsiString ~2^31 characters

WideString ~2^30 characters

Example:

var

a:string;

How to work with char

How to work with char

To work with char

Step 1

Description:

Delphi has three character types: Char, AnsiChar, and WideChar.

Declaration:

Type Contents

Char A single character

AnsiChar A single character

WideChar A single Unicode character

Example:

var

a:char;

How to work with Boolean

How to work with Boolean

To work with Boolean

Step 1

Description:

The four predefined Boolean types are Boolean, ByteBool, WordBool, and LongBool. Boolean is the preferred type.

Declaration:

Boolean ByteBool, WordBool, LongBool

False <> True

Ord(False) = 0 Ord(False) = 0

Ord(True) = 1 Ord(True) <> 0

Succ(False) = True Succ(False) = True

Pred(True) = False Pred(False) = True

Example:

if X <> 0 then ...;

var OK: Boolean

...

if X <> 0 then OK := True;

if OK then ...;

How to work with integer types

How to work with integer types

To work with integer types

Step 1

Description:

Fundamental integer types include Shortint, Smallint, Longint, Int64, Byte, Word, and Longword.

Declaration:

Type Range

Shortint –128..127

Smallint –32768..32767

Longint –2147483648..2147483647

Int64 –2^63..2^63–1

Byte 0..255

Word 0..65535

Longword 0..4294967295

Example:

var

a:integer;

b:integer;

c:integer;

How to add the item in the DBCombolBox

How to add the item in the DBCombolBox

To add the item in the DBCombolBox

Step 1

To add the item in the DBCombolBox, first, you need to click the Items properties.

Step 2

After that, insert the Item and finally, click the Ok button.

How to add the DBComboBo

How to add the DBComboBo

To add the DBComboBo

Step 1

To add the DBComBo, first, you need to move the mouse to the Data Control object toolbar and then click the DBComboxBo object.

Step 2

Now, you have to insert the DBComboBox in the Form1.

Step 3

Next, you need to select the DataSource and then select the Department in the DataField.

How to create the gender with checkbox

How to create the gender with checkbox

To create the gender with checkbox

Step 1

If you would like to create the gender with checkbox, first, double click the CheckBox1 and it will display a Code Explorer Window. Next, you need to insert the programming as followed;

  1. dbcheckbox1.Checked:=not checkbox1.Checked;
  2. table1.Edit;
  3. dbcheckbox1.Field.AsVariant:=dbcheckbox1.Checked;

How to create the gender with checkbox

How to create the gender with checkbox

To create the gender with checkbox

Step 1

To create the gender with checkbox, first you need to double click the DBCheckBox1 and then it will display a Code Explorer Window. Next, you need to insert the programming as followed;

checkbox1.Checked:=not dbcheckbox1.Checked;

How to create the gender with checkbox

How to create the gender with checkbox

To create the gender with checkbox

Step 1

To create the gender with checkbook, first, you need to double click the From1 and then it will display a Code Explorer Window. Later you need to insert the programming as followed;

  1. Table1.Active:=True;
  2. checkbox1.Checked:=not dbcheckbox1.Checked;

How to create the gender with checkbox

How to create the gender with checkbox

To create the gender with checkbox

Step 1

To create the gender with checkbook, first, move the mouse to the Standard object toolbar and then click the CheckBox object.

Step 2

After that, you need to insert the CheckBox in the Form1.

Step 3

Later, you need to enter the Female in the Caption.

How to create the gender with CheckBox

How to create the gender with CheckBox

To create the gender with CheckBox

Step 1

If you wish to create the gender with CheckBox, the first thing you need to do is to move the mouse to the Data Controls object toolbar and then click the DBCheckBox object.

Step 2

Next, you have to insert the DBCheckBox in the Form1.

Step 3

Later, select the DataSource and select the Gender in the DataField.

How to create the Department with Edit box

How to create the Department with Edit box

To create the Department with Edit box

Step 1

To create the Department with Edit box, first you need to move the mouse to the Data Controls object toolbar and then click the DBEdit object.

Step 2

Next, you have to insert the DBEdit in the Form1.

Step 3

Then, select the DataSource and select the Department in the DataField.

How to create the student name with Edit box

How to create the student name with Edit box

To create the student name with Edit box

Step 1

To create the student name with Edit box, first, you need to move the mouse to the Data Controls object toolbar and then click the DBEdit object.

Step 2

Next, you need to insert the DBEdit in the Form1.

Step 3

After that, select the DataSource and select the StudentName in the DataField.

How to create the student id with Edit box

How to create the student id with Edit box

To create the student id with Edit box

Step 1

To create the student id with Edit box, first, you need to move the mouse to the Data Controls object toolbar and then click the DBEdit object.

Step 2

Next, you need to insert the DBEdit in the Form1.

Step 3

Later, select the DataSource and then select the StudentID in the DataField.

How to create the Search button

How to create the Search button

To create the Search button

Step 1

To create the search button, the first thing you need to do is to add the Button in the Form1 and then rename the Caption to Search.

Step 2

Next, just double click the Button to show the Code Explorer Window and then set the Program as followed;

  1. var
  2. idno:string;
  3. find:boolean;
  4. begin
  5. idno:=inputbox(' Enter the Stuent No',
  6. ' Enter the No ','9732001');
  7. Table1.SetKey;
  8. Table1.Fields[0].AsString:=idno;
  9. find:=table1.GotoKey;
  10. if not find then
  11. ShowMessage(' No this Record ');
  12. end;

How to create the Delete button

How to create the Delete button

To create the Delete button

Step 1

To create the Delete button, first, add the Button in the Form1 and then rename the Caption to Delete.

Step 2

Next, just double click the Button to show the Code Explorer Window and you need to set the Program as followed;

  1. Table1.Delete;
  2. procedure TForm1.Table1BeforeDelete(DataSet:TDataSet);
  3. begin
  4. if messagedlg(' You want delete the data ',mtinformation,[mbyes,mbno],0)
  5. =mrno then abort();

  6. end;

Step 3

Now, you need type and insert the code and set the Program as followed;

procedure Table1BeforeDelete(DataSet: TDataSet);

How to create the Add Record button

How to create the Add Record button

To create the Add Record button

Step 1

To create the Add Record button, first, add the Button in the Form1 and then rename the Caption to Add Record.

Step 2

Double click the Button to show the Code Explorer Window and then set the Program as followed;

Table1.Append;

How to create the Last Record button

How to create the Last Record button

To create the Last Record button

Step 1

To create the last record button, first, add the Button in the Form1 and then rename the Caption to Last Record.

Step 2

Next, you have to double click the Button to show the Code Explorer Window and you need to set the Program as followed;

Table1.Last;

How to create the Next record button

How to create the Next record button

To create the Next record button

Step 1

To create the Next button, first, add the Button in the Form1 and then rename the Caption to Next.

Step 2

Next, double click the Button to show the Code Explorer Window and then you need to set the Program as followed;

Table1.Next;

How to create the Previous button

How to create the Previous button

To create the Previous button

Step 1

To create the previous button, first you need to add the Button in the Form1 and then rename the Caption to Previous.

Step 2

After that, double click the Button to show the Code Explorer Window and you need to set the Program as followed;

Table1.Prior;

How to create the Go To First button in the database

How to create the Go To First button in the database

To create the Go To First button in the database

Step 1

To create the Go To First button in the database, first, you need to add the Button in the Form1 and then rename the Caption to First Record.

Step 2

Next, you need to double click the Button to show the Code Explorer Window. And you need to set the Program as followed:

  1. Table1.First;

How to create the master or detail form

How to create the master or detail form

To create the master or detail form

Step 1

To create the master or detail form, first, you need to open the Database menu and then click the Form Wizard command.

Step 2

Next, in the From Option, select the Create a master/detail form and click the Next button.

Step 3

Now, you must select the master table that you want and click the Next button.

Step 4

Then, select the field that you want and later, click the Next button. You just need to follow the step by step wizard to finish it.

Step 5

Select the detail table that you want and click the Next button.

Step 6

Later, select the field that you want and then click Next button. You just need to follow the step by step wizard to finish it.

Step 7

Finally, you have finished and the picture below appears on your screen.