WhiteShadow
01-01-2007, 07:25 AM
Scripting Standards by White Shadow.
So why use standards, doesn't the code still frkkin` compile?!
Yes it does, but you may cause many people to go blind and also confuse yourself. People would learn from your code much faster too.
Now let's learn some standards:
CamelBackStyle - UpperCase the words in variables, procedures, program Names, functions, ect.
NO:
var
omgiamaleeth4x0r;
Yes:
var
OmgIAmALeetH4x0r;
*Don't forget to space twice. Did you notice you even read the 2nd one faster?
Always space after the begins and statements[if..then, while..do, for..to..do, ect.] - So people can tell what loop this part of the code is in.
NO:
procedure tutstandards;
begin
writeln('yo yo yo');
end;
Yes:
procedure TutStandards;
begin
Writeln('yo yo yo');
end;
NO:
program New;
procedure iamcool;
var i:string;
begin
i:='no your not';
if(i='no your not')then
begin
writeln('uh oh you are doushbag');
end;
end;
begin
iamcool;
end.
YES:
program New;
procedure IAmCool;
var
i : string;
begin
i:= 'no your not';
if(i = 'no your not')then
begin
Writeln('uh oh you are doushbag');
end;
end;
begin
IAmCool;
end.
1 Space at arithmetic signs too.
Be consistent with if thens - Put your damn if then statement.
NEVER:
program New;
{.include SRL/SRL.Scar}
begin
setupsrl;
findsymbol(x,y,'bank');
mouse(x,y,0,0,true,flag);
end.
Notice if the FindSymbol result were false you would click right at 0, 0. Detectable, and stupid yes?
YES:
program New;
{.include SRL/SRL.Scar}
begin
SetUpSRL;
if(FindSymbol(x, y, 'bank'))then
begin
Mouse(x, y, 0, 0, true);
Flag;
end;
end.
Beautiful, only clicks and flags when symbol is actually there. Notice, also space at each parameter, very clean and organized.
repeat..until - the code inside repeat until loops should always be 2 spaces from the repeat and the until aligned with the repeat.
NO:
program New;
{.include SRL/SRL.Scar}
begin
repeat
writeln('what the hell is this?');
writeln('don''t be gay don''t type like this!');
until(false)
end.
Yes:
begin
repeat
Writeln('Mmmhmm good job');
Writeln('I love you too, deary');
until(false)
end.
Parentheses - "(" Use them!
NO:
procedure number;
var num,num2:integer;
begin
num:=3;
num2:= 3;
if num=3 or num2=3then
writeln('yes');
end;
begin
number;
end.
This will actually give you an error. ^
Yes:
procedure Number;
var
num, num2 : Integer;
begin
num:= 3;
num2:= 3;
if(num = 3) or (num2 = 3)then
Writeln('yes');
end;
begin
Number;
end.
Notice the CamelBackStyle, space 1 the variable declarations, space 1 arithmetic signs, use parentheses, 2 spaces after a statement.
I add more later, the thing is space to show people different loops and shiet. Don't cram it or align it all to the left it's annoying!
I add more later! k thx for now.
White Shadow.
So why use standards, doesn't the code still frkkin` compile?!
Yes it does, but you may cause many people to go blind and also confuse yourself. People would learn from your code much faster too.
Now let's learn some standards:
CamelBackStyle - UpperCase the words in variables, procedures, program Names, functions, ect.
NO:
var
omgiamaleeth4x0r;
Yes:
var
OmgIAmALeetH4x0r;
*Don't forget to space twice. Did you notice you even read the 2nd one faster?
Always space after the begins and statements[if..then, while..do, for..to..do, ect.] - So people can tell what loop this part of the code is in.
NO:
procedure tutstandards;
begin
writeln('yo yo yo');
end;
Yes:
procedure TutStandards;
begin
Writeln('yo yo yo');
end;
NO:
program New;
procedure iamcool;
var i:string;
begin
i:='no your not';
if(i='no your not')then
begin
writeln('uh oh you are doushbag');
end;
end;
begin
iamcool;
end.
YES:
program New;
procedure IAmCool;
var
i : string;
begin
i:= 'no your not';
if(i = 'no your not')then
begin
Writeln('uh oh you are doushbag');
end;
end;
begin
IAmCool;
end.
1 Space at arithmetic signs too.
Be consistent with if thens - Put your damn if then statement.
NEVER:
program New;
{.include SRL/SRL.Scar}
begin
setupsrl;
findsymbol(x,y,'bank');
mouse(x,y,0,0,true,flag);
end.
Notice if the FindSymbol result were false you would click right at 0, 0. Detectable, and stupid yes?
YES:
program New;
{.include SRL/SRL.Scar}
begin
SetUpSRL;
if(FindSymbol(x, y, 'bank'))then
begin
Mouse(x, y, 0, 0, true);
Flag;
end;
end.
Beautiful, only clicks and flags when symbol is actually there. Notice, also space at each parameter, very clean and organized.
repeat..until - the code inside repeat until loops should always be 2 spaces from the repeat and the until aligned with the repeat.
NO:
program New;
{.include SRL/SRL.Scar}
begin
repeat
writeln('what the hell is this?');
writeln('don''t be gay don''t type like this!');
until(false)
end.
Yes:
begin
repeat
Writeln('Mmmhmm good job');
Writeln('I love you too, deary');
until(false)
end.
Parentheses - "(" Use them!
NO:
procedure number;
var num,num2:integer;
begin
num:=3;
num2:= 3;
if num=3 or num2=3then
writeln('yes');
end;
begin
number;
end.
This will actually give you an error. ^
Yes:
procedure Number;
var
num, num2 : Integer;
begin
num:= 3;
num2:= 3;
if(num = 3) or (num2 = 3)then
Writeln('yes');
end;
begin
Number;
end.
Notice the CamelBackStyle, space 1 the variable declarations, space 1 arithmetic signs, use parentheses, 2 spaces after a statement.
I add more later, the thing is space to show people different loops and shiet. Don't cram it or align it all to the left it's annoying!
I add more later! k thx for now.
White Shadow.