All pastes #30481 Raw Edit

Unnamed

public text v1 · immutable
#30481 ·published 2005-11-23 03:44 UTC
rendered paste body
// Learning Parameters
// Objective:
// Set variables One and Two in one procedure, and use them in another
program Parameters;
// I must first declare both One and Two globally.
var One, Two: Integer;

//In this procedure I will set both one and two.
//Notice in the parameters the word var prefixing..
procedure SetVars(var x1, x2: Integer);
begin
  GetMousePos(x1, x2); //Here I set both x1 and x2.
end;

//In This procedure I use One and Two.
//Notice in the parameters no prefixing...
procedure UseVars(y1, y2: Integer);
begin
  WriteLn(IntToStr(y1) + ' ' + IntToStr(y2)); //Here I output the values of y1 and y2
end;
//Main loop, here I call my procedures.
begin
//I am telling SetVars to output x1, and x2 to One and Two respectively.
SetVars(One, Two);
Wait(50);
//Now I will use One and Two in another procedure.
//Again I replace the parameters with One and Two respectively.
UseVars(One, Two);
//As you can see, UseVars will output the currrent Mouse Posistion
//To the debug box... UseVars got the Mouse Posistion from One and Two
// Which were set in the SetVars procedure
end.