[Delphi] Basic Delphi syntax.

Joined
Mar 23, 2007
Messages
931
Reaction score
11
I will show you some basic Delphi syntax. It's kinda dead language, but it's flexible and you can easily write complex apps in it.

Speed comparing?
VB < Delphi = C# < C++ < ASM
So don't doubt in it's speed.



PHP:
//We declare that this is a program with name: "Delhpi".
program Delphi;

//Application type is: CONSOLE.
{$APPTYPE CONSOLE}

//Program uses. Like "INCLUDE" in C++.
uses
  SysUtils;
//We write our variables here.
//Integer, string, etc, etc, etc... Default stuff.
var
  X, Y : integer;

//We begin to write our code and procedures here.
begin
//Some useless and fancy beginning introduction.
//WriteLn = Write Line.
WriteLn('Hello there, welcome to my frist program.');
//We declare X.
//ReadLn = Read Line.
ReadLn(X);
//We declare Y.
ReadLn(Y);
//Now we add these numbers together and print result.
//IntToStr = Converts Integers to String value.
WriteLn('Result is: ' + IntToStr(X + Y));


//We need the program to wait for our input so it will not close after pervouse statement.
ReadLn;
end.


If you like this syntax you can search google for resources and start learning it. It's easy.
 
Looks a little bit like ASM in the way it's written (program, end, etc...).

You can even make it more difficult / time intensive then ASM, you know? Look at brainfuck :P
 
It's not quite a tutorial. It's just showing the syntax. I can write a tutorial a it later about how can you use it to create joke programs and viruses.

Delphi is good language for n00b virus writers because it does not req any frameworks, just windows OS.
 
I wanted to get into Delphi back in the day (mainly its popular in the Malware community) but I didn't like the IDE its too weird for me, too much crap, it has sooo much........... But not a bad language ;P still it doesn't outperformanc VB.NET unless you're saying Delphi is NOT like C# considering C# is .NET and all .NET languages have the same 'powers'
 
Basic SCAR Script:

PHP:
program New;
{.include SRL/SRL.scar}

var I : Integer;

const
         RepeatTimes = 10; //Repeat x times

function TypeTheText(text: string): Boolean;
begin
 SendKeys(text+Chr(13));
end;

begin
 SetupSRL;
  repeat
   TypeTheText('Hello World!');
   I := I + 1;
  until(I = RepeatTimes);
end.

That's equal to:

PHP:
program New;
{.include SRL/SRL.scar}

var I : Integer;

const
         RepeatTimes = 10; //Repeat x times

begin
 SetupSRL;
  repeat
   SendKeys('Hello World'+Chr(13));
   I := I + 1;
  until(I = RepeatTimes);
end.

Using procedures and/or functions is really handy.
 
Back