This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#51 2012-02-23 08:16:26

slinger
Scratcher
Registered: 2011-06-21
Posts: 1000+

Re: Pascal Topic

Pascal Tutorial #5
---

This tutorial is on procedures and functions
(sorry for the delay D smile

==procedures==
A procedure is a section of code that the main program calls up. Procedures help to keep your code neat.

an example:

Code:

procedure welcome; //procedure
begin
  writeln('welcome to the program');
end;     

begin
  welcome; //calling it
end.

as can guess the "procedure" is what you sue to define a procedure and the "welcome;" is what you use to call the procedure welcome.

==functions==
The difference between a function and a procedure is that a function can return a value.

An example of a function:

Code:

function cubed(var x:integer):integer; //naming it
begin
  cubed := x*x*x; //cubing the number
end;

var
  number: integer;

begin //start the program
  writeln('enter a number');
  readln(number);//                   V using the function 'Cubed'.
  writeln('the number cubed is ', cubed(number));
end.

Take a look at the comments it's pretty self explanatory if you know how procedures work :3

---
next: loop, soooo totally forgot about those xD I'll do that soon :p


http://s0.bcbits.com/img/buttons/bandcamp_130x27_blue.png

Offline

 

#52 2012-02-23 09:15:30

LiFaytheGoblin
Scratcher
Registered: 2011-11-14
Posts: 1000+

Re: Pascal Topic

I just made my first "Hello World" program with lazarus  big_smile  yeah

Offline

 

#53 2012-02-23 09:16:33

slinger
Scratcher
Registered: 2011-06-21
Posts: 1000+

Re: Pascal Topic

Nice!  big_smile  Did you use my tutorials?


http://s0.bcbits.com/img/buttons/bandcamp_130x27_blue.png

Offline

 

#54 2012-02-23 09:31:08

LiFaytheGoblin
Scratcher
Registered: 2011-11-14
Posts: 1000+

Re: Pascal Topic

I read your tutorials, but I'm a beginner and don't know many things about pascal  big_smile 
so I used the youtube tutorial which you recommended to technoguyx

Offline

 

#55 2012-02-23 09:33:31

slinger
Scratcher
Registered: 2011-06-21
Posts: 1000+

Re: Pascal Topic

Oh yeah, forgot about that xD
ANyway nice  smile


http://s0.bcbits.com/img/buttons/bandcamp_130x27_blue.png

Offline

 

#56 2012-02-24 06:53:57

slinger
Scratcher
Registered: 2011-06-21
Posts: 1000+

Re: Pascal Topic

Does anyone know any port tutorials?
edit: nvm found something, if anyone is interested http://delphi.about.com/od/networking/N … Delphi.htm
also look at this http://wiki.lazarus.freepascal.org/Networking

Last edited by slinger (2012-02-24 08:14:33)


http://s0.bcbits.com/img/buttons/bandcamp_130x27_blue.png

Offline

 

#57 2012-02-27 00:02:39

slinger
Scratcher
Registered: 2011-06-21
Posts: 1000+

Re: Pascal Topic

bump
About to write a loop tutorial  smile


http://s0.bcbits.com/img/buttons/bandcamp_130x27_blue.png

Offline

 

#58 2012-02-28 09:05:48

slinger
Scratcher
Registered: 2011-06-21
Posts: 1000+

Re: Pascal Topic

Pascal Tutorial #6
---

This tutorial is on loops

Loops as you probably already know repeat xD

==repeat until loop==

Code:

i := 1;
repeat
  i := i+1;
until i = 10;

As you can see this code here repeats until i = 10.

==for loop==

Code:

for i := 1 to 5 do
  begin
   writeln(i) ;
  end;

this repeats without you having to increment  smile

==while loop==

Code:

while i = 10 do
begin
  i = i+1;
end;

this repeats, you must increment or you'll go into an infinite loop.

Those are the main loops :3

---
next I have no idea xD


http://s0.bcbits.com/img/buttons/bandcamp_130x27_blue.png

Offline

 

#59 2012-03-12 05:26:06

slinger
Scratcher
Registered: 2011-06-21
Posts: 1000+

Re: Pascal Topic

Cool fact, game maker was made in pascal see here.
edit: not that I like gamemaker but lots of people use it; just thought it was interesting :p

Last edited by slinger (2012-03-12 05:27:20)


http://s0.bcbits.com/img/buttons/bandcamp_130x27_blue.png

Offline

 

#60 2012-03-19 03:40:54

slinger
Scratcher
Registered: 2011-06-21
Posts: 1000+

Re: Pascal Topic

Bumping, come on people, you don't know a good language when you see one...


http://s0.bcbits.com/img/buttons/bandcamp_130x27_blue.png

Offline

 

Board footer