Jump to content

Delphi/Pascal?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
7 replies to this topic

#1
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
I have Delphi and Pascal, and im a 'PRO' in pascal but I know nothing in Delphi!
If the Code of Delphi is like Pascal why when I load a program i made in Pascal it shows alot of errors?? and instead of a form can you use the shell ( Ms-DOS ) as PASCAL does?

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Delphi the language is two things: a language called Object Pascal (Pascal + OOP), and a library for doing GUI work. Delphie the product is the language plus a RAD environment.

Because Delphi is a descendent of Pascal, it doesn't work the same way, and Pascal code won't compile under a Delphi compiler. They have different expectations.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
Oww, so they are not like each other but not exactly! Delphi has some more things!
Thanks!

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Check out the Lazarus Projectif you'd like to try an open-source clone of Delphi.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
Thanks I will give it a look!

#6
Lop

Lop

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,172 posts

WingedPanther said:

Check out the Lazarus Projectif you'd like to try an open-source clone of Delphi.

Never heard of this until now! I'm looking into it now, looks neat.

#7
wojtekkk87

wojtekkk87

    Newbie

  • Members
  • Pip
  • 4 posts
Hi!
Please give some code. Propably You haven't use libraries. In Delphi You have another lik in pascal. f.eg. you don't use Crt but SysUtils ;)

#8
R-G

R-G

    Programmer

  • Members
  • PipPipPipPip
  • 142 posts
All variables in Delphi Script are always of Variant type. Typecasting is ignored.

Types in variables declaration are ignored and can be skipped, so these declarations are correct:

var a : integer;
var b : integerr;
var c, d;

Types of parameters in procedure/function declaration are ignored and can be skipped. For example, this code is correct:

function sum(a, b) : integer;
begin
result := a + b;
end;

Type of array elements is ignored and can be skipped so these declarations are equal:
var x : array [1..2] of double;
var x : array [1..2];

These keywords are ignored:
interface, implementation, program, unit
You can use them but they have no effect.

"in" directive in uses is ignored

Delphi Script doesn't support type declarations. It tries to skip them but
complex declarations may cause parser to fail.

^ and @ operators are not supported.

You can't use the function name to set the return value, use Result to do so.

Nested routines are supported but you can't use variables of top level function from the nested one.

The following keywords are not supported:
as, asm, class, dispinterface, exports, finalization, inherited, initialization, inline, interface, is, library, object, out, property, record, resourcestring, set, type

The following directives are not supported (note that some of them are obsolete and aren't supported by Delphi too):
absolute, abstract, assembler, automated, cdecl, contains, default, dispid, dynamic, export, external, far, implements, index, message, name, near, nodefault, overload, override, package, pascal, private
protected, public, published, read, readonly, register, reintroduce, requires, resident, safecall, stdcall, stored, virtual, write, writeonly

These RTL functions aren't supported in Delphi Script:
Abort, Addr, Assert, Dec, FillChar, Finalize, Hi, High, Inc, Initialize, Lo, Low, New, Ptr, SetString, SizeOf, Str, UniqueString, VarArrayRedim, VarArrayRef, VarCast, VarClear, VarCopy

Open array declaration is not supported.

CASE can be used for any types. So you can write
case UserName of
'Alex', 'John' : IsAdministrator := true;
'Peter' : IsAdministrator := false;
else
raise('Unknown user');
end;

Raise can be used without parameters to re-raise the last exception. You can also use Raise with string parameter to raise the exception with the specified message string. For example,
Raise(Format('Invalid value : %d', [Height]));

Threadvar keyword is treated as Var

[...] set constructors are not supported. You can use MkSet to create a set. For example,
Font.Style := MkSet(fsBold, fsItalic);

Set operator In is not supported. Use InSet to check whether a value is a member of set. For example,
if InSet(fsBold, Font.Style) then
ShowMessage('Bold');

Note, that set operators '+', '-', '*', '<=', '>=' don't work correctly. You have to use logical operators. For example,
ASet := BSet + CSet; should be changed to ASet := BSet or CSet;

CreateObject can be used to create objects that will be implicitly freed when no longer used. So instead of
procedure proc;
var l;
begin
l := TList.Create;
try
// do something with l
finally
l.Free;
end;
end;
you can write
procedure proc;
var l;
begin
l := CreateObject(TList);
// do something with l
end;

Built in function Evaluate can be used to interpret string as program code during runtime of a program and execute the code contained in the string. For example, you can write script like Evaluate(ProcNames[ProcIndex]);
and the procedure which name is specified in ProcNames[ProcIndex] will be called.

Built in directive UseUnit can be used to dynamically add to uses section any unit at runtime. For example, the following script
if FileExists('Update.pas') then
begin
UseUnit('Update.pas');
Evaluate('Update.DoUpdate');
end;
checks whether the unit named Update.pas exists and if so calls DoUpdate method from there.

UnloadUnit directive unloads any unit added by "uses" section or with UseUnit call.
Like an angel without a sense of mercy.