PDA

View Full Version : SCAR Script Official Standards



Bam Bam
11-01-2006, 08:31 PM
Indenting will be two spaces per level. You can indent by selecting text in SCAR and pressing Ctrl+Shift+U and Ctrl+Shift+I.

Margins will be set to 80 characters. Try not to make too long lines.

The begin statement appears on its own line. The end statement always
matches the begin statement by columns.
Example:
http://i12.tinypic.com/4l6jtj6.gif

Do not combine two or more statements on a single line. Write each on its own line.

Use semicolons at the end of the lines where appropriate. SCAR allows lines without semicolons but you should use them everywhere, except after var, begin, then, else repeat, do and before else.

Use spaces after commas and arithmetical signs.
Example:
http://i6.tinypic.com/5xysgm0.gif

There shall never be white space between an open parenthesis and the next character.
Example:
http://i10.tinypic.com/5xzdezt.gif

Object Pascal language reserved words and key words shall always be completely lowercase. Never capitalize words that SCAR displays in bold. It's completely unnecessary and looks ugly!

Routine names shall always begin with a capital letter and be camel-capped for readability.
Example:
http://i6.tinypic.com/4tabotf.gif

Routines shall be given names meaningful to their content. Routine name DoStuffWithSyAndSy is not meaningful, but name OutputProgressReport is.

Where possible, procedure and function formal parameters of the same type shall be combined into one statement
Example:
http://i18.tinypic.com/53slime.gif

All formal procedure and function parameter names will be meaningful to their purpose.

All functions should always return some value. Do not rely on SCAR initializing procedure return value automatically!

Variables will be given names meaningful to their purpose. That includes local and loop control variables, although in this case single character names are acceptable.

Boolean variable names must be descriptive enough so that their meanings of True and False values will be clear.

Variable declarations start in next line after var statement and are indented.
Example:
http://i15.tinypic.com/4tf19bp.gif

Use of global variables is discouraged. However, they may be used when necessary. Global variable naming rules are as follow:
Forms and controls are prefixed with their individual prefixes. Examples: frmMainForm, lblUser, txtPassword, imgPreview etc.
DTMs will be marked with dtm prefix as in dtmFishingSpot.
Character sets will be marked with chr prefix as in chrChatChars.
Bitmaps will be marked with bmp prefix as in bmpFishingNet.
Include global variables will be marked with g prefix then include initials as in gOsiStartTime.
Normal global variables will be marked with g prefix as in gNumFishCaught.

Type names that are reserved words shall be completely lowercase as in string. For other variable names, the first letter shall be uppercase, and the rest shall be camel-capped for clarity as in Integer.

The most likely case to execute in an if/then/else statement shall be placed in the then clause, with less likely cases residing in the else clause(s). This improves performance as well as readability.

If multiple conditions are being tested in an if statement, conditions should be arrange from left to right in order of least to most computation intensive. If condition statement is complex, replace it with function or Boolean variable with a meaningful name. This improves readability and makes code self-documenting.

Use of informational file header is encouraged for all script and include files.
Use Script > Script Properties from SCAR menu to enter script information.


These standards ensures readability of your code and enables easier maintaining of scripts written by other people.

[Source = http://kaitnieks.com/scar/scriptingsta/ ]

botmaster
11-01-2006, 09:08 PM
Wow. Finally I can bring my scripts up to standards :D. Thanks for the tut, there's just so much disputes over Standards out there I realize that sometimes it may be hard finding valid info :(.

Nice tut ;)

Bam Bam
11-01-2006, 09:41 PM
Wow. Finally I can bring my scripts up to standards :D. Thanks for the tut, there's just so much disputes over Standards out there I realize that sometimes it may be hard finding valid info :(.

Nice tut ;)

This isn't just a Tut these are THE original standards (if you look at citation) :D

YoHoJo
11-01-2006, 10:52 PM
WONDERFULL
everyone always talks about "standards" and people know what most of them are but ther isnt like one guide saying what "THE standsards" are. good job!

Yakman
11-01-2006, 11:35 PM
iv read the site a while ago, the only standard i picked up is the use of the prefix dtm and bmp for the handles.
you might have noticed iv got dtmBankers or dtmWater in a few scripts

theres also some small useful ones like putting the conditons of if statements in their most likely order

but this was useful to look at when i was writing stuff that would go into SRL

Bebe
11-01-2006, 11:43 PM
Been following these since a month into my SCAR scripting "career" :cool:

Bam Bam
11-03-2006, 07:59 PM
I posted a download for the post source anyone who wants to feel free to redistribute this...

Hey321
01-17-2007, 12:02 AM
Ok, most of that makes sense to me (i think :o), but there's one thing i don't understand:

Type names that are reserved words shall be completely lowercase as in string. For other variable names, the first letter shall be uppercase, and the rest shall be camel-capped for clarity as in Integer.

What does camel-capped mean?

Hey321
01-17-2007, 12:03 AM
Ok, most of that makes sense to me (i think :o), but there's one thing i don't understand:

Type names that are reserved words shall be completely lowercase as in string. For other variable names, the first letter shall be uppercase, and the rest shall be camel-capped for clarity as in Integer.

What does camel-capped mean?

pwnaz0r
01-18-2007, 04:08 AM
ok dang i not been doin some of that stuff better hop to it =p

GoF
06-10-2007, 04:57 PM
Aren't these from kaitnieks.com..? Maybe you should credit kait for making the standards, if they are from kaitnieks.com

Spky
06-10-2007, 05:21 PM
Aren't these from kaitnieks.com..? Maybe you should credit kait for making the standards, if they are from kaitnieks.com


[Source = http://kaitnieks.com/scar/scriptingsta/ ]

Everyone adapts their own standards anyway. Mine are like:


procedure DoSomething(Param : Integer);
var
I : Integer;
begin
I:= Param * (Param * 100) / 100;
if(Something)then
begin
DoSomething;
Etc;
end
else
DoSomethingElse;
end;

Markus
06-10-2007, 05:22 PM
[Source = http://kaitnieks.com/scar/scriptingsta/ ]

:)
edit: beaten by Spky, only one minute!!!1!11!!!

Smartzkid
08-02-2007, 03:15 AM
Awesome tut for beginners; maybe this should get stickied?

Santa_Clause
08-02-2007, 03:19 AM
Nice bump Smartz :p

LordGregGreg
08-13-2007, 05:10 PM
i think this si worth a bump, I havnt found a place to be as detailed and definative as this. I wil have to change a few things.

yes!! smei colons!!!!!

no!! no caps :( lol

Bam Bam
08-31-2007, 07:27 PM
If this got stickyfied it would be my first sticky :)

Edit:

Thanks Wizzup :)

Wizzup?
08-31-2007, 09:38 PM
First Sticky. ;)

Method
09-02-2007, 10:27 PM
A little late, but thanks for these Bam Bam. They make scripts look very neat, which is a necessity for running any type of script.

gothicly2
09-03-2007, 12:29 AM
Useful for organizing the scripts!

kamikeza
09-05-2007, 04:17 PM
i wish someone could learn me scripting step by step send me mail if u want to

TheSantaMan
09-06-2007, 04:58 AM
kk great you don't need to post ur URL on my script. You script your way i'll script mine. So don't be a narb and just post ur URL and nothing else.

Fruity-Lo0py
09-14-2007, 08:08 PM
Thanks for helping me!

applesauce121
09-23-2007, 12:48 AM
Thanks Nice tut! Really Helped.

lalaland
10-03-2007, 10:35 PM
Thanks for this dude, I am VERY new to scripting. I will make all my scripts to these standerds. Thanks!

Jimi_Blue
10-31-2007, 06:21 PM
Bookmarked as a checklist for when my first script is done. Ty for writing.

Tri
11-02-2007, 01:30 PM
Thanks, I never knew if there were certain standards when making a script, but now I do.. :)

Puffo
11-28-2007, 03:19 PM
Gr8 tut...Were was somthing i dident understod but Thanks for making this tut it helped me a lot :p

V3l0ld0
12-01-2007, 05:28 PM
Nice tut. Helped me alot.

thank you

Naum
12-13-2007, 06:03 PM
Ty bam this helped me

XunTric
12-19-2007, 02:13 PM
Great tutorial, thanks =)

Relath
01-10-2008, 03:11 AM
This has actually made scripting 100x easier for me, by making everything clearer to read and identify for when i make mistakes or when i want to add something to the script. Thanks man.

pizzownage
01-12-2008, 04:16 AM
wow, I never actually knew the standards. This is great, thanks.

Pizzownage

Griff
02-19-2008, 01:12 AM
thank you! I am learning so much with all of these scripts!

Griff
02-19-2008, 01:13 AM
oops last post i meant tuts not scripts, not thinking :D

ShadowMinion
03-02-2008, 01:29 PM
Thanks, I believe there are many different versions of 'correct' standards but if i go by yours i can't go far wrong :)

Many Thanks
ShadowMinion [exppo]

exppo
03-05-2008, 09:21 PM
Thanks, helped sooo much now i can bring my standards up to what is truly expected :)

Exppo

p.s: Thanks a milllioooon...

Blaze
03-15-2008, 06:49 PM
Good thing I found this before I started scripting!

yomama`
03-20-2008, 12:53 AM
Use semicolons at the end of the lines where appropriate. SCAR allows lines without semicolons but you should use them everywhere, except after var, begin, then, else repeat, do and before else.


I don't mean to sound like the syntax police... but semicolons in pascal work different; unlike C for example, pascal dosn't use semi's for a line terminator... instead semi's are used as separators...

Just think:
"Should I put in a semicolon? Only if the next thing is a statement!"


yes its not a problem for the compiler... it's just redundant :D


There is some more information about it on this website (also a resource that I used for this post):
http://everything2.com/index.pl?node_id=1108617

hope I was of some help.

This will probably just confuse everyone however.... meh... maybe someone else might be able to explain it better :P lol

ritz
03-28-2008, 03:35 AM
Well the scripting is much like VB but the semicolons remind me of Java and C++.

Once i get a bit of time, i will try to learn the language.. they are all pretty much the same once you understand the core logic behind it... so i hope it isn't too hard to pick up. :)

PvH
04-21-2008, 06:32 PM
thanks.. i really needed this:D
thanks to you that my script has better standards now
thanks:)
rep++ for you for helping me:cool:

Bam Bam
04-26-2008, 10:55 PM
thanks.. i really needed this:D
thanks to you that my script has better standards now
thanks:)
rep++ for you for helping me:cool:

You know, thank you.
I don't get a whole lot of that even when I do manage to make myself useful. xD

- Bam Bam

benjaa
05-05-2008, 10:12 PM
brilliant! just what ive been looking for, THANKYOU

akad_ad
05-16-2008, 02:55 PM
veary nice tut. i have lerned so much, thanks.

mattlox 2
06-04-2008, 08:18 PM
i have a question so the stuff that i just looked at about making scripts i need to include in all mine to become jr member

WithoutFear
07-03-2008, 06:50 PM
finally...i have been working on my first script but I could not locate any set standard rules. Now i can learn the right way!

rep++ :)

Cerium
07-04-2008, 11:10 AM
Good to know the standards:)

SonOfSheep
07-31-2008, 01:03 AM
This is great to follow if you write without a standard. I use them as guidelines and not rules. I'm all for letting the code flow freely and then fixing readability!

deadman2
08-04-2008, 03:25 AM
This will help with some scripting. Good for posting it now people know the standards.

paradox
08-04-2008, 03:53 AM
This helped a lot Thank you

acestar
09-25-2008, 11:06 PM
Hah. Thanks very much. I appreciate the easy access to the standards in this forum, especially since I've been trying to learn everything I can about scripting.

RichNubzor
11-26-2008, 03:45 AM
wonderful, thanks :).. If I know c++, vb, php/mysql, perl, and html/css this should be a walk in the park?

tls
02-08-2009, 01:15 AM
Bump... people read this through thoroughly ... Great Thread!

Da 0wner
02-08-2009, 02:45 AM
Yes, because you really need to bump stickies...

tls
02-08-2009, 04:00 AM
Yes, because you really need to bump stickies...

True, but I guess I wanted people to notice it...

Da 0wner
02-08-2009, 05:09 AM
Oh yeah, the bold text or the latest post thing?

tls
02-08-2009, 07:04 AM
yes... [/endofconversation]

Lacky
02-09-2009, 08:09 AM
Hmm...someone should create a script where you copy and paste your script into a form, and it makes your script have the official standards. Kind of like that SRL Member Application Tool Script, but after you paste you script in and click ok, it fixes it up for you.

EDIT: I am sure that tweaking that script a bit would do the job...perhaps. :p

Da 0wner
02-13-2009, 10:14 AM
Not really...that script is really simple :D. This would take more time.

Bam Bam
07-09-2009, 10:51 AM
Code formatters already exist. The point of this tutorial is to teach people how to format their code properly without relying on one of these tools.

Its like spell check vs just knowing how to spell.

Da 0wner
07-09-2009, 10:55 AM
Nielsie made a formatter.

A Random Guy
04-21-2010, 11:26 PM
What about constants? Should they be all caps, or just named like any other variable?

Coh3n
04-21-2010, 11:28 PM
What about constants? Should they be all caps, or just named like any other variable?
It's really up to the scripter. Personally, I use all caps. This is a standard in Java, and it easily distinguishes between whether you have a constant/variable/proc/func.