SRL Archive - Outdated Tutorials

SCAR Script Official Standards


Bam Bam

2006-11-01 15:31:16

  • 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:
  • 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:
  • There shall never be white space between an open parenthesis and the next character.
  • Example:
  • 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:
  • 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:
  • 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:
  • 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

2006-11-01 16:08:50

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

2006-11-01 16:41:18

From: botmaster
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

2006-11-01 17:52:18

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

2006-11-01 18:35:28

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

2006-11-01 18:43:28

Been following these since a month into my SCAR scripting "career" :cool:

Bam Bam

2006-11-03 14:59:06

I posted a download for the post source anyone who wants to feel free to redistribute this…

Hey321

2007-01-16 19:02:02

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

2007-01-16 19:03:05

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

2007-01-17 23:08:06

ok dang i not been doin some of that stuff better hop to it =p

GoF

2007-06-10 12:57:02

Aren't these from kaitnieks.com..? Maybe you should credit kait for making the standards, if they are from kaitnieks.com

Spky

2007-06-10 13:21:26

From: GoF
Aren't these from kaitnieks.com..? Maybe you should credit kait for making the standards, if they are from kaitnieks.com


From: Bam Bam
[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

2007-06-10 13:22:11

From: Bam Bam

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

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

Smartzkid

2007-08-01 23:15:22

Awesome tut for beginners; maybe this should get stickied?

Santa_Clause

2007-08-01 23:19:28

Nice bump Smartz :p

LordGregGreg

2007-08-13 13:10:55

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

2007-08-31 15:27:57

If this got stickyfied it would be my first sticky :)

Edit:

Thanks Wizzup :)

Wizzup?

2007-08-31 17:38:19

First Sticky. ;)

Method

2007-09-02 18:27:26

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

2007-09-02 20:29:04

Useful for organizing the scripts!

kamikeza

2007-09-05 12:17:09

i wish someone could learn me scripting step by step send me mail if u want to

TheSantaMan

2007-09-06 00:58:27

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

2007-09-14 16:08:59

Thanks for helping me!

applesauce121

2007-09-22 20:48:05

Thanks Nice tut! Really Helped.

lalaland

2007-10-03 18:35:17

Thanks for this dude, I am VERY new to scripting. I will make all my scripts to these standerds. Thanks!

Jimi_Blue

2007-10-31 14:21:56

Bookmarked as a checklist for when my first script is done. Ty for writing.

Tri

2007-11-02 09:30:13

Thanks, I never knew if there were certain standards when making a script, but now I do.. :)

Puffo

2007-11-28 10:19:43

Gr8 tut…Were was somthing i dident understod but Thanks for making this tut it helped me a lot :p

V3l0ld0

2007-12-01 12:28:17

Nice tut. Helped me alot.

thank you

Naum

2007-12-13 13:03:15

Ty bam this helped me

XunTric

2007-12-19 09:13:41

Great tutorial, thanks =)

Relath

2008-01-09 22:11:47

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

2008-01-11 23:16:28

wow, I never actually knew the standards. This is great, thanks.

Pizzownage

Griff

2008-02-18 20:12:00

thank you! I am learning so much with all of these scripts!

Griff

2008-02-18 20:13:01

oops last post i meant tuts not scripts, not thinking :D

ShadowMinion

2008-03-02 08:29:47

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

2008-03-05 16:21:17

Thanks, helped sooo much now i can bring my standards up to what is truly expected :)

Exppo

p.s: Thanks a milllioooon…

Blaze

2008-03-15 14:49:40

Good thing I found this before I started scripting!

yomama`

2008-03-19 20:53:23

From: Bam Bam

[*]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

2008-03-27 23:35:56

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

2008-04-21 14:32:38

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

2008-04-26 18:55:30

From: pvh
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

2008-05-05 18:12:25

brilliant! just what ive been looking for, THANKYOU

akad_ad

2008-05-16 10:55:20

veary nice tut. i have lerned so much, thanks.

mattlox 2

2008-06-04 16:18:34

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

2008-07-03 14:50:45

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

2008-07-04 07:10:32

Good to know the standards:)

SonOfSheep

2008-07-30 21:03:22

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

2008-08-03 23:25:35

This will help with some scripting. Good for posting it now people know the standards.

paradox

2008-08-03 23:53:35

This helped a lot Thank you

acestar

2008-09-25 19:06:39

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

2008-11-25 22:45:09

wonderful, thanks :).. If I know c++, vb, php/mysql, perl, and html/css this should be a walk in the park?

mormonman

2009-02-07 20:15:32

Bump… people read this through thoroughly … Great Thread!

Da 0wner

2009-02-07 21:45:02

Yes, because you really need to bump stickies…

mormonman

2009-02-07 23:00:16

From: Da 0wner
Yes, because you really need to bump stickies…


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

Da 0wner

2009-02-08 00:09:04

Oh yeah, the bold text or the latest post thing?

mormonman

2009-02-08 02:04:38

yes… [/endofconversation]

Lacky

2009-02-09 03:09:52

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

2009-02-13 05:14:47

Not really…that script is really simple :D. This would take more time.

Bam Bam

2009-07-09 06:51:40

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

2009-07-09 06:55:47

Nielsie made a formatter.

A Random Guy

2010-04-21 19:26:54

What about constants? Should they be all caps, or just named like any other variable?

Coh3n

2010-04-21 19:28:37

From: A Random Guy
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.