0% found this document useful (0 votes)
54 views24 pages

IT NOTES CODEx

Uploaded by

khuselopanya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views24 pages

IT NOTES CODEx

Uploaded by

khuselopanya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

IT NOTES

Basic Codes - Maths

- Abs : Returns the absolute value - Inc : Increments an Integer


variable
of a integer or real number
by specified value
rReal := abs(-123,45) // Returns
123,45 iInt := 5;

- *Ceil : Rounds the value Inc(iInt); // iInt = 6

up to the nearest whole number - *Max: Determines maximum between


two numbers
iInt := ceil(123,65); // iInt = 124
iInt := Max(123,321); // iInt = 321
iInt := ceil(123,45); //iInt = 124
- *Min: Determines minimum between
- Dec : decrements an Integer
two numbers
variable by 1.
iInt := Min(123,321); // iInt = 123
iInt := 5;
- Mod: The modulus, mods number1 by
Dec(iInt); //iInt = 4
number2
- Div : used for integer division.
iInt := 10 mod 3; // iInt = 1
For real numbers use /
- *Power : Raises the first number
iInt := 10 div 3; // iInt = 3 to pwer of second

rReal := 12.34 / 4; // rReal = Real := Power(2,3); // iInt = 8


3,085
- Round function rounds a real-type
- Frac: Returns the fractional
value to an integer-type value
part of a real number
iInt := Round(123.65); // iInt =
rReal := frac(4.41); // rReal = 124;
0.41
iInt := Round(123.45); // iInt -
- *Floor : Rounds the value down 123;

to the nearest whole number - Sqr: returns the square of a int


or real
iInt := floor(123.65); // iInt =
123 iInt := srq(2); // iInt = 4

iInt := floor(123,45); // iInt = - Srqt: returns the square root


123
iInt := sqrt(4); // iInt = 2
String Code
When indexing strings, the last occurence of a substring
first character in a string.

starts at position 1. iInt :=


LastDelimiter('1','12341');
- Copy: Returns a substring
// iInt
of a string
= 5
sStr := Copy('Delphi',4,6);
// sStr = phi - Lowercase : Returns a
string in lowercase form
- Delete : Deletes a
substring from a string sStr := Lowercase('dElPhi');
// sStr =
beginning at a specified
point 'delphi'

sStr := 'Deplphi'; - Position : Returns the


index value of the
Delete(sStr,3,1); // sStr =
'Delphi' first character in a
specified substring that
- Insert : Inserts a
substring into a string occurs in a given string

beginning at a specified iInt := pos('p','Delphi'); //


point iInt = 4

sStr := 'Dephi'; - Trim : removes whitesspaces


from a string
Insert('l',sStr,3); // sStr =
'Delphi' sStr := Trim(' Delphi '); //
sStr =
- Length : Returns the number
of characters in a 'Delphi'

string - Uppercase : Returns a


string, in Uppercase
iInt := Length('Delphi'); //
iInt = 6 format

- LastDelimiter : Returns the sStr := Uppercase('dElPhi');


position of the // sStr =
'DELPHI'
Validation
Validate a editbox for only Validate a editbox for only
strings numbers
procedure procedure
TForm2.Button1Click(Sender: TForm2.Button1Click(Sender:
TObject); TObject);
var n : integer; var n : integer;
sInput : string; sInput : string;
begin begin
sInput := Edit1.Text; sInput := Edit1.Text;
for n:= 1 to Length(sInput) for n:=1 to length(sInput)
do do
begin begin
if not (sInput[n] if not (sInput[n] < '0') or
(sInput[n] >
in['A'..'Z','a'..'z']) then
'9') then
ShowMessage('Error! Letter
at ' + ShowMessage('Error! Letter
at ' +
sInput[n] + ' not a
character'); sInput[n] + ' not a number');
end; end;
end; end;
Array
Array Declaration Insert a value into an array
Numbers: array[1..10] of Using a while loop:
Integer;
var i : integer;
Names: array[1..5] of
arrNumbers : array[1..10] of
string;
integer;
Marks: array[0..4] of real;
begin
Assigning Values to Array
i := 1;
Names[1] := 'Don'; // string
while i <= 10 do
array
begin
for iInt:= 1 to 10 do //
integer array arrNumbers[i] := i;
begin i:=i+1 ;
Numbers[iInt] := iInt; end;
end; end;
Retrieving Values from Array Using a for loop:
ShowMessage(Names[1]); //Don var i : integer;
ShowMessage(IntToStr(Numbers[ arrNumbers : array[1..10] of
5])); //5 integer;
Assign a value into an array begin
in the
for i := 1 to 10 do
declaration:
arrNumbers[i] := i;
var arrDays : array[1..7] of
end;
string =
('Monday','Tuesday','Wednesda Using a Repeat Loop
y','Thursday','Friday','Satur
var i : integer;
day','Sunday');
arrNumbers : array[1..10] of
arrScore: array[1..3] of
integer;
integer = (4,5,2);
begin
i := 1;
repeat Read 10 names from the
keyboard into an
arrNumbers[i] := i;
array and display the names
i := i+1;
in a rich edit
until i&lt;= 10;
var i: Integer;
end;
nameArray : Array[1..10] of
string;

Using User Input begin

var Names : array[0..9] of for i:=1 to 10 do


string;
begin
iIndex : integer;
nameArray[i] :=
begin inputBox('Names','Type in

for iIndex := 0 to 9 do a name','');

begin end;

Names[iIndex] := for i:= Low(nameArray) to


Inputbox('Names','Enter In A High(nameArray)
Name Below','');
do
end;
begin
end;
Using the High / Low redOut.Lines.Add(nameArray[i]
Functions );

Marks : array[1..5] of real end;


=
end;
(85.34,86.74,75.43,76.23,95.3
);
Read 10 Names from Keyboard Search an Array
into an array,
const Marks : array[1..5] of
and display the names in real =
alphabetic order
(85.34,86.74,75.43,76.23,95.2
var 3);
i,j : integer; var iInt : integer;sStr :
string;
s: string;
bFound : boolean;rFound :
arrNames: Array[1..10] of
real;
string;
begin
begin
sStr := InputBox('Enter in
for i:=1 to 10 do
Search
begin
String','Enter string','');
arrNames[i] :=
rFound := StrToFloat(sStr);
InputBox('Names','Type in
bFound := false;
a name','');
iInt := 1;
end;
while (iInt <= High(Marks))
for i := 1 to 9 do
and (bFound =
for j:= i+1 to 10 do
false) do
if arrNames[i] > arrNames[j]
begin
then
if Marks[iInt] = rFound then
begin
begin
s := arrNames[i];
ShowMessage('Found Item: ' +
arrNames[i] := arrNames[j];
sStr + ' at
arrNames[j] := s;
pos ' + IntToStr(iInt));
end;
bFound := true;
for i:=1 to 10 do
end
else
redOut.Lines.Add(arrNames[i])
; ShowMessage('Not Found!');
end; inc(iInt);
Sort an Array ascending order if (arrNum[i] &gt;
arrNum[j]) then
const arrNum : array[1..7] of
integer = begin
(2,4,6,1,0,9,6); temp := arrNum[j];
var i,j,temp : integer; arrNum[j] := arrNum[i];
begin arrNum[i] := temp;
for i := 1 to length(arrNum) end;
-1 do
end.
for j := i + 1 to
Assigning Values to Array
length(arrNum) do
Names[1] := 'Don'; // string
if (arrNum[i] &gt;
array
arrNum[j]) then
for iInt:= 1 to 10 do //
begin
integer array
temp := arrNum[j];
begin
arrNum[j] := arrNum[i];
Numbers[iInt] := iInt;
arrNum[i] := temp;
end;
end;
Assign a value into an array
end. in the
Sort an Array descending declaration:
order
var arrDays : array[1..7] of
const arrNum : array[1..7] of string =
integer =
('Monday','Tuesday','Wednesda
(2,4,6,1,0,9,6); y','Thursday',
var i,j,temp : integer; 'Friday','Saturday','Sunday')
;
begin
arrScore : array[1..3] of
for i := 1 to length(arrNum)
integer = (4,5,2);
-1 do
for j := i + 1 to
length(arrNum) do
Using User Input Search an Array
var Names : array[0..9] of const Marks : array[1..5] of
string; real
=(85.34,86.74,75.43,76.23,95.
iIndex : integer;
23);
begin
var iInt : integer;sStr :
for iIndex := 0 to 9 do string;

begin bFound : boolean;rFound :


real;
Names[iIndex] :=
Inputbox('Names','Enter In A begin
Name Below','');
sStr := InputBox('Enter in
Search

Read 10 names from the String','Enter string','');


keyboard into an
rFound := StrToFloat(sStr);
array and display the names
bFound := false;
in a rich edit
iInt := 1;
var i: Integer;
while (iInt <= High(Marks))
nameArray : Array[1..10] of
and (bFound = false) do
string;
begin
begin
if Marks[iInt] = rFound then
for i:=1 to 10 do
begin
begin
ShowMessage('Found Item: ' +
nameArray[i] :=
sStr + ' at
inputBox('Names','Type in a
name',''); pos ' + IntToStr(iInt));
end; bFound := true; end
for i:= Low(nameArray) to else
High(nameArray) do
ShowMessage('Not Found!');
begin
inc(iInt);
end;
redOut.Lines.Add(nameArray[i]
); end;
2D Array

Declare a 2D Array var row,col : integer;

var arrNums : str : string;


array[1..3,1..4] of integer;
begin
- arrNums : name of 2D array
for row := 1 to 3 do
- 1..3 : number of rows
begin
- 1..4 : number of columns
str := '';
for col := 1 to 4 do
Intialize 2D array with
begin
random values
str := str +
procedure
inttostr(arrNums[row,col]) +
TForm1.btnInitializeClick(Sen
der: ' ';

TObject); end;

var row,col : integer; redOutput.Lines.Add(str);

begin end;

for row := 1 to 3 do end;

for col := 1 to 4 do Get the sum of rows in a 2D


Array
begin
var row,col,rowSum : integer;
arrNums[row,col] :=
random(9)+1; begin

end; for row := 1 to 3 do

end; begin

Print the elements inside of rowSum := 0;


the 2D
for col := 1 to 4 do
Array
begin
procedure
rowSum := arrNums[row,col] +
TForm1.btnPrintElementsClick(
rowSum;
Sender: TObject);
end;
redOutput.Lines.Add('Sum of
row:' + intto
str(row) + ' = ' +
inttostr(rowSum));
end;
Get the sum of columns in a
2D Array
var row,col,colSum : integer;
begin
for col := 1 to 4 do
begin
colSum := 0;
for row := 1 to 3 do
begin
colSum := arrNums[row,col] +
colSum;
end;
redOutput.Lines.Add('Sum of
col:' + inttostr(col) + ' = '
+
inttostr(colSum));
end;
end;
Text File
-ReWrite : Opens file as new
Text File Functions ReWrite(myFile);
-AssignFile : Assigns your -Reset : Opens a file for
Text File to a Read Access
variable for Use Reset(myFile);
AssignFile(myFile,'Test.txt') - Append : Opens a file for
; appending at end
-CloseFile: Closes the file Append(myFile);
CloseFile(myFile); - Read : Read one Letter at a
time
-EOF: Tests whether the file
position is at the read(myFile,cChar);
end of a file. - ReadLn : Reads a Line of
Text and goes to Next
while not EOF(myFile) do
Line
begin
readln(myFile,sStr);
ReadLn(myFile,text);
- Rename : Changes the name
ShowMessage(text);
of an external file.
end;
Rename(myFile, 'Test1.txt');
FileExists: The fileexists
- Write : Writes to A File
function returns
write(myFile, 'Some Text Here
True if the given FileName
');
file exists.
- WriteLn : Writes to a File
if not fileexists('Test.txt')
in a New Line
then
writeln(myFile, 'Hello
Showmessage('File does not
World');
exist');
Reading from a Text File
var sDescription :=
Copy(sStr,iIndex+1);
myFile : textFile;
end;
sStr,sBrowserName,sDescriptio Closefile(myFile);
n : string;
end;
iIndex : integer;
end
begin
Writing to a Text File
if Not FileExists('sample-
procedure
data.txt') then
TForm1.btnWriteClick(Sender:
ShowMessage('File does not
TObject);
exist')
var myFile : textFile;
else
sLine : string;
begin
begin
AssignFile(myFile,'sample-
data.txt'); AssignFile(myFile,
'output.txt');
Reset(myFile);
Append(myFile);
while not eof(myFile) do
sLine := edtInput.Text;
begin
Writeln(myFile,sLine);
Readln(myFile,sStr);
redOutput.Lines.Add(sLine);
iIndex := Pos('#',sStr);
CloseFile(myFile);
sBrowserName :=
Copy(sStr,1,iIndex-1); end
ADO
Accessing a single column in begin
the table
tblRentals.First;
redOutput.Lines.Add('Rental_I
end
D:' + #9 +
inttostr(tblRentals['Rental_I
D'])); Loop through all records in a
table
redOutput.Lines.Add('Start_Da
te:' + #9 + procedure
TfrmCarRent.btnTotalStartKmCl
datetostr(tblRentals['Start_D
ick(Sender: TObject);
ate']));
var iSum : integer;
begin
Navigational Commands
iSum := 0;
Allows you to navigate
records in the table tblRentals.First;
tblRentals.First // Moves while not tblRentals.Eof do
pointer to the
begin
first record
iSum := iSum +
tblRentals.Prior // Moves tblRentals['Start_Km'];
pointer to record
tblRentals.Next;
one before current record
end;
tblRentals.Next // Moves
redOutput.Clear;
pointer to the next
redOutput.Lines.Add('Total
record
Start_Km = ' +
tblRentals.Last // Moves
inttostr(iSum) + ' Kms');
pointer to the last
end;
record
procedure
TfrmCarRent.btnRentalsFirstCl
ick(Sender: TObject);
Count all the records in a inttostr(tblRentals.RecordCou
table nt));
procedure end;
TfrmCarRent.btnTotalRecordsCl
Modify Commands
ick(Sender: TObject);
The modify commands,
var iTotalRecords : integer;
correspond to the SQL
begin
Update, Insert and Delete,
iTotalRecords := 0; and allow you to make
tblRentals.First; changes to the table.
while not tblRentals.Eof do tblPlayers.Edit // Puts the
dataset in edit
begin
mode
inc(iTotalRecords);
tblPlayers.Insert // Puts the
tblRentals.Next;
dataset in insert mode
end;
tblPlayers.Delete // Puts the
redOutput.Clear; dataset in delete mode
tblPlayers.Post // Writes the
redOutput.Lines.Add('TotalRec change to current record to
ords = ' + the database

inttostr(iTotalRecords)); 6 Inserting a Record into the


table
end;
The Insert statement is
There is a built-in method
responsible for putting
that does the exact
the table into insert mode,
same thing called
and Post statement is
RecordCount:
responsible for saving any
procedure changes.
TfrmCarRent.btnRecordCountCli
procedure
ck(Sender: TObject);
TfrmCarRent.btnInsertClick(Se
begin nder: TObject);

redOutput.Clear; begin

redOutput.Lines.Add('TotalRec tblRentals.Insert;
ords = ' +
tblRentals['Vehicle_ID'] := tblRentals['Start_Date'] :=
strtoint(edtVe strToDate(edtStart_Date.Text)
;
hicle_ID.Text);
tblRentals['Stop_Date'] :=
tblRentals['Driver_ID'] :=
strToDate(edtStop_Date.Text);
strtoint(edtDriver_ID.Text);
tblRentals.Post;
tblRentals['Start_Km'] :=
strtoint(edtStart_Km.Text); redOutput.Clear;
tblRentals['Stop_Km'] := redOutput.Lines.Add('New
strtoint(edtStop_Km.Text); Record Succesfully
tblRentals['Start_Date'] := Edited');
strToDate(edtStart_Date.Text)
end;
;
DELETE A RECORD FROM THE
tblRentals['Stop_Date'] :=
TABLE
strToDate(edtStop_Date.Text);
procedure
tblRentals.Post;
TfrmCarRent.btnDeleteYearTwen
end; tyClick(Sender: TObject);
Edit Recrods in a table var iCount : integer;
procedure begin
TfrmCarRent.btnEditClick(Send
iCount := 0;
er:
tblRentals.First;
TObject);
while not tblRentals.Eof do
begin
begin
tblRentals.Edit;
if
tblRentals['Vehicle_ID'] :=
pos('2020',datetostr(tblRenta
strtoint(edtVe
ls['Start_Date'])) > 0 then
hicle_ID.Text);
begin
tblRentals['Driver_ID'] :=
tblRentals.Delete;
strtoint(edtDriver_ID.Text);
inc(iCount);
tblRentals['Start_Km'] :=
strtoint(edtStart_Km.Text); tblRentals.First;
tblRentals['Stop_Km'] := end;
strtoint(edtStop_Km.Text);
tblRentals.Next;
end;

redOutput.Lines.Add(inttostr(
iCount) + ' Records
Deleted');
end;
SQL column, you must use the
Group By Statement
Aggregate Functions
Find how many times the "Cha-
An aggregate function
Cha" was
performs some mathematic
operations on a column. danced per week :

Usage : SELECT
Week,Count(TypeOfDance) from
SELECT
tblResults where
AggregateFunction(ColumnName)
TypeOfDance='Cha-Cha' GROUP
FROM
BY
tableName;
Week;
Min : Returns the minimum
Find how many couples where
value from a column:
Eliminated
SELECT MIN(Score) from
per week:
tblResults;
SELECT Week,Count(Result)
Max : Return the maximum
from tblResults
value from a column:
WHERE Result="Eliminated"
SELECT MAX(Score) from
GROUP BY Week;
tblResults;
Find which TypeOfDance
Sum : Returns the sum from a
yielded the
column :
highest score :
SELECT SUM(Score) from
tblResults; SELECT TypeOfDance,AVG(Score)
FROM tblResults GROUP BY
Avg : Returns the average
TypeOfDance ORDER BY AVG(-
from a column :
Score) desc;
SELECT AVG(Score) from
tblResults; As

Count : Counts the Number of The as statement renames a


values in a column: column in the output:

SELECT Count(Song) from Usage:


tblResults;
SELECT column AS renameHere
When using Aggregate FROM table;
functions on more than one
Renaming the output Column: Select a Date from the table
based on
SELECT Song AS renameSong
from tblResults ; some criteria:
Between The between statement SELECT GameDate FROM tblGames
selects values in a certain WHERE
range. Usage:
GameDate=#2016/01/11#
SELECT column1 FROM table
Select the current Date using
BETWEEN value1 and value2
NOW():
Show those DanceCoupleIDs
SELECT NOW();
that have a score in the
range of 20 and 30: Select the Day from a Date
using DAY():
SELECT DanceCoupleID,Score
FROM tblResults SELECT DAY(#2016/01/11#);
WHERE Score BETWEEN 20 AND Select those Players born in
30; September:
Which could have also been SELECT Name, DateOfBirth FROM
rewritten as: tblPlayers
SELECT DanceCoupleID,Score where Month(DateOfBirth) = 9;
FROM tblResults
Show the age of each Dam:
WHERE Score >= 20 AND Score
SELECT DamName, (Year(Now())
<= 30;
- YearCompleted) as Age from
tblDams;
Show those Videos that where Insert a New Date into the
published table:
beteween the dates 23 January INSERT INTO tblGames VALUES
2015 and 31 (76,
December 2015: #2017/12/24#, "HM008", 250,
5566);
SELECT VideoTitle,
DatePublished FROM Video Format
WHERE DatePublished BETWEEN The Format statement, formats
a number into a specific
#2015/01/23# AND #2015/12/31#
format.
Usage: on a criteria, but with a few
differences. The HAVING
SELECT FORMAT(column1,1) FROM
statement is applied after
table;
the GROUP BY Statement,
Format a column to 2 Decimal whilst the WHERE statement is
Places: applied before the GROUP BY.
Another difference is that
SELECT FORMAT(Score,"0.00")
the HAVING STATEMENT can
from tblGames;
filter aggregrate results.
14.5.2 Working out the The syntax for this statement
Average Score, and is as follows:

displaying to three decimal Usage:


places
SELECT column FROM table_name
SELECT DanceCoupleID, WHERE condition GROUP BY
FORMAT(AVG(- column HAVING

Score),"0.000") AS condition;
AverageScore FROM
For every TypeOfDance, get
tblResults GROUP BY the Max Score
DanceCoupleID;
that is greater than 35:
Using Format with "Currency":
SELECT TypeOfDance,MAX(Score)
SELECT MONTH(PaymentDate) as FROM tblResults GROUP BY
MonthNum TypeOfDance HAVING MAX

FORMAT(Sum(GrossSalaryDeducti (Score) > 35;


ons),"Currency") AS
Delete
TotalAmountPaid
The DELETE statement will
FROM tblPayments GROUP BY
delete a row within a
MONTH(PaymentDate);
table.
Usage:
Having
DELETE FROM table WHERE
The Having statement is
condition;
similar to the WHERE
Example:
statement, allowing columns
to be filtered based DELETE FROM tblResults WHERE
TypeOfDance LIKE('%Swag%');
Distinct GROUP BY column.
The Distinct statement Example:
eliminates duplicate values
SELECT
from a column, and only
Week,Count(TypeOfDance),TypeO
returns distinct values.
fDance
Usage:
FROM tblResults WHERE
SELECT DISTINCT column1,
TypeOfDance='Cha-Cha' GROUP
colum FROM table;
BY Week;
Show the different dance
SELECT Endangered, Count(*)
types:
AS CountAnimals
SELECT DISTINCT TypeOfDance
FROM tblCarnivores Group By
FROM tblResults;
Endangered;
Example:
SELECT Month(PaymentDate) AS
SELECT DISTINCT Province FROM
MonthNum
tblTowns,
FORMAT(Sum(GrossSalaryDeducti
tblDams WHERE tblTowns.DamID
ons),"Currency") AS
=
TotalAmountPaid
tblDams.DamID AND River =
FROM tblPayments GROUP BY
"Vaal River";
MONTH
Group By
(PaymentDate);
The Group By statement is
Insert
used when you have the
The INSERT statement allows
repeating values occuring in
us to add a row into a table.
Columns. It groups
Usage:
these multiple occurence of
values, into INSERT INTO
table(column1,column2)
disctinct values. It is often
used with aggregate VALUES(value1,value2);
functions.
Example :
Usage:
SELECT columnsFROM table
WHERE condition
INSERT INTO tblResults Find all Songs that start
with B:
(RoutineNo,Week,Round,DanceCo
upleID,TypeOfDance,Song,Score SELECT Song from tblResults
,Result) VALUES where SONG
('120','13','2','15','Classic LIKE('B%');
al','Symphony
Find all RoutineNos that
5','40','Eliminated'); obtained a score of 30 or
greater:
You can also use the INSERT
statement like this SELECT RoutineNo,Score from
tblResults WHERE Score
Usage:
LIKE('3_');
INSERT INTO table
Order By
values(value1, value2);
The order by statement is
Example:
used to arrange output
INSERT INTO tblGames VALUES
in alphabetical order. When
(76, #2017/12/24#, "HM008",
the order by
250, 5566);
statement is not specified,
Like
results from the
The Like operator allows us
table are displayed in the
to search for a
order they are found.
matching pattern within a
With order by you can specify
column.
Ascending or
Usage:
Descending order:
SELECT column FROM table
Usage:
WHERE column LIKE
SELECT column FROM table
pattern
WHERE criteria
It works alongside two
Order By column
wildcards:
Example:
% – The percent sign
represents zero, one, or SELECT
DanceCoupleID,TypeOfDance
multiple characters
from
_ – The underscore represents
tblResults where result =
a single character
"Safe" ORDER BY TypeOfDance
desc;
Select
The select statement
retrieves data from the
table, based on the column
you specify.
Usage:
SUpdate
The UPDATE statement allows
us to update a field value
within a table.
Usage:
UPDATE table SET column WHERE
condition;
Example:
UPDATE tblResults SET
TypeOfDance='Swag'
WHERE RoutineNo='120';ELECT
column FROM table;
Where
The Where clause allows us to
specify criteria,
to narrow down our results to
what we want.
Usage:
SELECT column FROM table
WHERE criteria;
Dates and Time sYear := copy(myDate,1,4);
// 20
Getting the current date and
time sMonth := copy(myDate,6,2);
// 09
procedure
TForm2.Button1Click(Sender: sDay := copy(myDate,9,2);
//01
TObject);
Richedit1.Lines.Add(sDay + '
var
' + sMonth + ' ' + sYear);
myDate,myTime : string;
end;
begin
myTime := TimeToStr(Time);
// 18:45:19
myDate := DateToStr(Date);
// 2020/09/01
Richedit1.Lines.add(myTime +
' ' + myDate);
end;

Isolating the Day, Month and


Year
procedure
TForm2.Button1Click(Sender:
TObject);
Var
myDate,myTime,sYear,sMonth,sD
ay : string;
begin
myTime := TimeToStr(Time);
// 18:45:19
myDate := DateToStr(Date);
// 2020/09/01
OOP fdislikes := 0;

Class Definition end;

type Class Procedure with


Parameters
TVideo = class
procedure
private
tvideo.AddNewComment(scomment
fvideoname : string; : string; sdate: string);

fcomments : string; begin

flikes : integer; fcomments := #13 + scomment


+ #9 + sdate + #13;
fdislikes : integer;
end;
frating : integer;
Class Function
public
function tvideo.GetRating;
constructor create(sname :
string); var i : integer;

procedure sline : string;


AddNewComment(scomment,sdate
begin
:
sLine := '';
string);
for i:= 0 to frating do
procedure SetRating;
begin
function GetRating : string;
sline := sline + '*';
procedure addLike;
end;
procedure addDislike;
result := sline;
function tostring : string;
end; Misc
end;
Getting a value from a
Class Constructor
comboxbox, or listbox:
constructor
String name := cmblist.text
tvideo.create(sname: string);
or
begin
cmbList.Items[cmbList.ItemInd
fvideoname := sname; ex] – retrieve the selected
item in the combo box.
flikes := 0;

You might also like