Wire
2014-06-14 14:03:16
I'm currently following Cohen beginners script tutorial and do not fully understand why this method would be used over the one i provided. I understand he was attempting to provide an example of function but wouldn't it be far easier to use procedure than function in this scenario? I believe the reason i do not understand his example fully is because there is a local variable, so it would only effect this section and not furthering anything else. Please explain why this would be more ideal over procedure as i'm most likely wrong. Thanks Wire_
Sidenote- Why does he include string; in the name? I understand function will return a answer while procedure will not. So the main purpose of function would be to receive an answer that can further the script like failsafes or checking for certain objects?
function WeAreBored: string;
var
s: String;
begin
Result := 'What are we going to do now?';
s := 'We are very bored chopping all these logs!';
Wait(500);
WriteLn(s);
end;
VERSUS
procedure WeAreBoredTest;
begin;
WriteLn('What are we going to do now?');
WriteLn('We are very bored chopping all these logs!');
Wait(500);
end;
Sidenote- Why does he include string; in the name? I understand function will return a answer while procedure will not. So the main purpose of function would be to receive an answer that can further the script like failsafes or checking for certain objects?
function WeAreBored: string;
var
s: String;
begin
Result := 'What are we going to do now?';
s := 'We are very bored chopping all these logs!';
Wait(500);
WriteLn(s);
end;
VERSUS
procedure WeAreBoredTest;
begin;
WriteLn('What are we going to do now?');
WriteLn('We are very bored chopping all these logs!');
Wait(500);
end;