From: Alek000
I know what my problem is with it, I don't know when to use a procedure or a function. I'm not sure what to do when to make it work basically.
If you have previous programming experience think of a procedure as a
void function, that is it returns nothing (void) something.
Usually you'd use a procedure to name a block of code to keep it clean, or remove repetitiveness, for example you may have..
procedure MyInfo;
begin
WriteLn('Name: Craig');
WriteLn('Age: 16');
end;
etc etc, it doesn't return a value it just writes my details to the debug, i use a procedure because it allows my main code to be clean with a simple MyInfo; call rather than just having the two WriteLns there.
On the other hand functions return a value and this is very useful, for example I might want to have a function to check if i'm old enough to drink in the UK, ie.
function AbleToDriveAt(age: Integer): Boolean;
begin
Result := (age >= 17);
end;
this again makes my main code more beautiful because it's easier to read at first glance:
if AbleToDriveAt(17) then
WriteLn('woohoo you can drive!');
hope i haven't explained that badly