SRL Archive - Delphi/FPC Help and Tutorials

Differnce between = and :=


RuneDragon

2012-05-17 06:05:02

I see assignment use = and some times :=

What is the difference between the two.


program new;

var
NumHerbToClean:Integer;

begin

NumHerbToClean := 28;

if NumHerbToClean == 28 then
begin
Writeln('I want stone');
end;


end.

I made a simple script. But is not working. The error is on line


if NumHerbToClean == 28 then

How do i check value of variable ?

masterBB

2012-05-17 06:07:36

We use = as an equel sign.

if a = b then
writeln('a equals b');

we use := to set a variable.

a := 2;
b := a;

John

2012-05-17 06:08:43

This may be wrong but := stands for an integer, = means If it is "ThisSTring" then blahblah…
This:
if NumHerbToClean == 28 then
Should be This:
if NumHerbToClean = 28 then
E: Ninja'd
E#2: Oh and this should be Here

iBlank

2012-05-17 06:11:22

From: John
This may be wrong but := stands for an integer, = means If it is "ThisSTring" then blahblah…
This:
if NumHerbToClean == 28 then
Should be This:
if NumHerbToClean = 28 then
E: Ninja'd


A plain = can be used for an integer as well, as long as it has already been set with a := earlier in the script.

Rich

2012-05-17 07:25:09

Also = is used to set constants.

So
const
ThisConstant = 28;

RuneDragon

2012-05-17 10:06:44

Thanks everyone for the help.

@John first i was thinking to ask on SRL Help. But this is general programing help, so posted here.

I googled, found

http://www.functionx.com/objectpascal/Lesson16.htm

At the end of the page, it lists operators.


== Equality to


Simba don't use exact pascal operators ?

masterBB

2012-05-17 10:09:35

From: RuneDragon
Thanks everyone for the help.

@John first i was thinking to ask on SRL Help. But this is general programing help, so posted here.

I googled, found

http://www.functionx.com/objectpascal/Lesson16.htm

At the end of the page, it lists operators.



Simba don't use exact pascal operators ?


That last table is wrong. In the rest of that article they are talking about =. Also the language you are writing in simba is pascalscript not pascal, but yeah, we do use the pascal operators.