PDA

View Full Version : Using Proper Scripting Standards



Abyssal
04-22-2007, 03:27 PM
The first thing we are going to cover is when to capitalize words, and when to make them lowercase.
Usually, you make a word lowercase when it turns bold in SCAR, as a rule of thumb. Most other words are uppercase. For example, here is a sample script that uses improper standards:

Program hereisMYstandards;
Var Variable1: integer; variable2: String;
Procedure DoThis;
Begin
Variable1 := strtoInt(variable2);
End;
Begin
DoThis;
End.

As you can see, there are quite a few things wrong with this.

For one, the word integer should be capitalized, and string should be lowercased. That follows the bold rule.

Also, program, procedure, begin and end all are bolded and should be lowercase.

The title of the script is also a bit out of whack, if it were mine I would have it say "HereIsMyStandards" or something like that.

Indenting! You should use a 2-3 space indent. Usually you use indents after a new procedure, after "var", after "const", after begins and ends and after if then statements. Also, after many bolded words. Such as repeat etc.

Also, spacing things out 1 or 2 lines after a listing of variables, or a new procedure helps keep things in order.



Please keep in mind most of these are very basic, easy things to follow and are not 100% complete standards. But following just these few will definitely make your script look tons better. Have a look at the completed script above, with standards.

program HereIsMyStandards;

var
Variable1: Integer;
Variable2: string;

procedure DoThis;
begin
Variable1:= StrToInt(Variable2);
end;

begin
DoThis;
end.


Remember, these are only a few of the standards that should be used. Just try and follow these and soon your scripts will look perfect :)

~Abyssal

Ejjman
04-22-2007, 05:39 PM
add repeat..unitil
add cases
add fors
add labels

Harry
05-19-2007, 04:03 PM
This tut is anorexic...

add the things Ejjman1 said please.

Bebe
05-19-2007, 04:19 PM
Yeah, you need to expand this tutorial.

Include more example and maybe even use a real script.