Recent

Author Topic: Place Procedure  (Read 1542 times)

GreatUnka

  • Newbie
  • Posts: 2
Place Procedure
« on: March 24, 2019, 12:08:28 pm »
Where in the general structure of a lazarus 2.0.0 program do you place a procedure, and what is the correct syntax for it. :'(

Thausand

  • Sr. Member
  • ****
  • Posts: 292
Re: Place Procedure
« Reply #1 on: March 24, 2019, 12:19:39 pm »
If simple pascal program can look example: https://www.tutorialspoint.com/pascal/pascal_program_structure.htm

if lazarus program can look example: http://wiki.freepascal.org/Unit

If want better answer maybe other user can explain. My english bad  :-[

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Place Procedure
« Reply #2 on: March 24, 2019, 01:09:05 pm »
Where in the general structure of a lazarus 2.0.0 program do you place a procedure, and what is the correct syntax for it. :'(

That question is too general: One answer? Wherever it'll do most good :)

If you really know nothing about Pascal (as your question seems to imply), start here: Object Pascal Tutorial and keep searching for and reading other tutorials and trying simple programs until you get the knack of it.

Then, when you have a concrete question (for example when it's better to use an independent proc vs. an object's method), come back and ask. We will do our utmost to help you.

Best of lucks!
« Last Edit: March 24, 2019, 01:10:42 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

GreatUnka

  • Newbie
  • Posts: 2
Re: Place Procedure
« Reply #3 on: March 24, 2019, 02:26:38 pm »
Dear Lucamar,

as you are aware I am a Newbie to this type of Pascal.

Your suggestion to go away and dig more into this is a good suggestion.

Kind Regards
GreatUnka ;)

Zvoni

  • Hero Member
  • *****
  • Posts: 2315
Re: Place Procedure
« Reply #4 on: March 24, 2019, 10:54:32 pm »
Well, since you're a newbie, one iron rule for procedures/functions:
A function/procedure (Header and code) must come before it's called
(and to all others: don't start with forward-declaration!)

Code: Pascal  [Select][+][-]
  1. //Works
  2. Procedure AProcedure;
  3. Begin
  4.   Writeln('Hello Word');
  5. End;
  6.  
  7. Procedure AnotherProcedure;
  8. Begin
  9.   AProcedure; //Calling "AProcedure"
  10. End;
  11.  
Code: Pascal  [Select][+][-]
  1. //This doesn't work
  2. Procedure AnotherProcedure;
  3. Begin
  4.   AProcedure; //Calling "AProcedure"
  5. End;
  6.  
  7. Procedure AProcedure;
  8. Begin
  9.   Writeln('Hello Word');
  10. End;
  11.  
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

 

TinyPortal © 2005-2018