Page 1 of 2 12 LastLast
Results 1 to 25 of 40

Thread: SRL/Simba Standards (with examples)

  1. #1
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,787
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

    Default SRL/Simba Standards (with examples)

    Standards are a set of rules that you should follow to ensure that the code you write is easily readable not only you but others as well. This is a must if you want to apply for SRL Members or even want help on your code, it allows people to read and understand what your doing, so if you need help, others can easily find the problem, if you apply for members, people can read what you do so they can decide if your ready. Overall it makes your code look a lot neater, nicer to look at and much easier to read.

    This tutorial is for people who want to use proper standards in their scripts but want examples on how they should do them
    I realised that there was not already a tutorial which done this, so i decided to write it

    All information has come from the original standards post from Kaitnieks http://www.kaitnieks.com/scar/scriptingsta/

    Indenting will be two spaces per level. You can indent by selecting text in Simba and pressing Tab and decrease the indent by pressing Shift+Tab.
    Simba Code:
    {YES}
    begin
      Writeln('Hi');
      Writeln('This is indented');
    end;

    {NO}
    begin
    Writeln('Hi');
    Writeln('This is not indented');
    end;
    Margins will be set to 80 characters. Try not to make too long lines.
    Simba Code:
    {YES}
      i := SomeProcedure(x, y, f, r, t) + SomeProcedure(x, y, f, r, t) +
           SomeProcedure(x, y, f, r, t) + SomeProcedure(x, y, f, r, t) +
           SomeProcedure(x, y, f, r, t) + SomeProcedure(x, y, f, r, t);
    {NO}
      i := SomeProcedure(x, y, f, r, t) + SomeProcedure(x, y, f, r, t) + SomeProcedure(x, y, f, r, t) + SomeProcedure(x, y, f, r, t) + SomeProcedure(x, y, f, r, t) + SomeProcedure(x, y, f, r, t);

    The begin statement appears on its own line. The end statement always matches the begin statement by columns.
    Simba Code:
    {YES}
    begin
      begin
        Writeln('Hi');
        Writeln('This is indented');
      end;
    end;

    {NO}
    begin
    begin
      begin
        Writeln('Hi');
        Writeln('This is indented');
      end;
    end;
    end;

    Do not combine two or more statements on a single line. Write each on its own line.
    Simba Code:
    {YES}
      i := 1;
      x := 3;
     
    {NO}
      i := 1; x := 3;

    Use semicolons at the end of the lines except after var, begin, then, else, repeat, do and before else.
    Simba Code:
    {YES}
    var
      i: Boolean;
      x: Integer;
     
    begin
      if (i) then
        Writeln('hi')
      else
      begin
        repeat
          i := True;
        until(i);
      end;
      for (x := 0) to 3 do
        Writeln(x);
    end;
     
    {NO}
    var;
      i: Boolean;
      x: Integer;
     
    begin;
      if (i) then;
        Writeln('hi');
      else;
      begin;
        repeat;
          i := True;
        until(i);
      end;
      for (x := 0) to 3 do;
        Writeln(x);
    end;

    Use spaces after commas and arithmetical signs.
    Simba Code:
    {YES}
    i := 2 + 3 + 5;

    {NO}
    i := 2+3+5;
    There shall never be white space between an open parenthesis and the next character.
    Simba Code:
    {YES}
    Writeln('Correct');

    {NO}
    Writeln( 'Incorrect' );
    Object Pascal language reserved words and key words shall always be completely lowercase. Never capitalize words that Simba displays in bold. It's completely unnecessary and looks ugly!
    Simba Code:
    {YES}
    var
      s: string;
      i: Integer;

    begin
      for (i := 0) to 3 do
      Writeln(i);
      if (i = 3) then
        Writeln('i = 3');
      repeat
        Writeln(s);
      until(s = '');
    end;

    {NO}
    Var
      s: String;
      i: Integer;

    Begin
      For (i := 0) To 3 Do
      Writeln(i);
      If (i = 3) Then
        Writeln('i = 3');
      Repeat
        Writeln(s);
      Until(s = '');
    End;
    Routine names shall always begin with a capital letter and be PascalCase for readability.
    Simba Code:
    {YES}
    procedure FormatHardDrive;

    {NO}
    procedure formatharddrive;
    Routines shall be given names meaningful to their content.
    Simba Code:
    {YES}
    procedure Proggy;

    {NO}
    DoStuffWithStuff
    Where possible, procedure and function formal parameters of the same type shall be combined into one statement
    Simba Code:
    {YES}
    procedure Test(x, y, z, a, b, c: Integer; f, g: string);

    {NO}
    procedure Test(x: Integer; y: Integer; z: Integer; a: Integer; b: Integer; c: Integer; f: string; g: string);
    All formal procedure and function parameter names will be meaningful to their purpose.
    Simba Code:
    {YES}
    procedure ScreenCoords(x1, y1, x2, y2: Integer);

    {NO}
    procedure ScreenCoords(a, b, c, d: Integer);
    All functions should always return some value. Do not rely on Simba initializing procedure return value automatically!
    Simba Code:
    {YES}
    function ReturnNumber: integer;
    begin
      {do stuff}
      Result := 123;
    end;

    {NO}
    function ReturnNumber: integer;
    begin
      {do stuff}
    end;
    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.
    Simba Code:
    {YES}
    var
      BoneDTM, BankSymb, Flax: Integer;

    {NO}
    var
      DTM1, DTM2, DTM3: Integer;
    Boolean variable names must be descriptive enough so that their meanings of True and False values will be clear.
    Simba Code:
    {YES}
    var
      FoundColor: Boolean;

    {NO}
    var
      a: Boolean;
    Variable declarations start in next line after var statement and are indented.
    Simba Code:
    {YES}
    var
      x, y, z: Integer;

    {NO}
    var x, y, z:Integer
    Use of global variables is discouraged. However, they may be used when necessary.

    Not really a example for this one, but whenever you can use local variables, use them instead of global variables.

    DTMs will be marked with dtm prefix.
    Simba Code:
    {YES}
    var
      dtmFishingSpot, BoneDtm: Integer;

    {NO}
    var
      FishingSpot, Bone: Integer;
    Bitmaps will be marked with bmp prefix.
    Simba Code:
    {YES}
    var
      bmpFishingSpot, BoneBmp: Integer;

    {NO}
    var
      FishingSpot, Bone: Integer;
    Type names that are reserved words shall be completely lowercase. For other variable names, the first letter shall be uppercase, and the rest shall be camel-capped for clarity.
    Simba Code:
    {YES}
    var
      i: Integer;
      s: string;

    {NO}
    var
      i: integer;
      s: String;
    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 theelse clause(s). This improves performance as well as readability.
    Simba Code:
    {YES}
    var
      b: Boolean;

    begin
      b := True;
      if (b) then
        Writeln('b is true')
      else
        Writeln('b is false');
    end;

    {NO}
    var
      b: Boolean;

    begin
      if (b) then
        Writeln('b is true')
      else
        Writeln('b is false');
    end;
    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 readibility and makes code self-documenting.
    Simba Code:
    {YES}
    var
      Bool1, Bool2: Boolean;

    begin
      Bool1 := True;
      Bool2 := False;
      if (Bool1 or Bool2) then
        Writeln('hi');
    end;

    {OR}
    var
      Bool1, Bool2: Boolean;

    function OneIsTrue: Boolean;
    begin
      Result := Bool1 or Bool2;
    end;

    begin
      Bool1 := True;
      Bool2 := False;
      if (OneIsTrue) then
        Writeln('hi');
    end;

    {OR}
    var
      Bool1, Bool2, Resultant: Boolean;

    begin
      Bool1 := True;
      Bool2 := False;
      Resultant := Bool1 or Bool2;
      if (Resultant) then
        Writeln('hi');
    end;

    {NO}
    var
      Bool1, Bool2: Boolean;

    begin
      Bool1 := True;
      Bool2 := False;
      if (Bool2 or Bool1) then
        Writeln('hi');
    end;

    enjoy

    ~shut
    Last edited by Shuttleu; 05-05-2013 at 11:46 AM.

  2. #2
    Join Date
    May 2007
    Location
    Everywhere
    Posts
    1,432
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Great job

    Random question:
    For loops you have
    i:=0 (no spaces)
    For inputting data to variables you have:
    bool1:= True; (1 space)

    Minor minor point indeed, but do you think both should be the same? Different?
    I personally do what you do with for loops (i:=0), though I've always done declaration like:
    x := 5;

  3. #3
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,787
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

    Default

    Quote Originally Posted by cstrike View Post
    Great job

    Random question:
    For loops you have
    i:=0 (no spaces)
    For inputting data to variables you have:
    bool1:= True; (1 space)

    Minor minor point indeed, but do you think both should be the same? Different?
    I personally do what you do with for loops (i:=0), though I've always done declaration like:
    x := 5;
    good point
    i suppose my standards is generaly good, but when it comes to loops they are sloppy

    it should be
    Simba Code:
    x:= 5;
    and
    Simba Code:
    for (x:= 0) to 5 do

    ima update first post

    ~shut

  4. #4
    Join Date
    Dec 2006
    Location
    /dev/null, home of the lolis.
    Posts
    10,859
    Mentioned
    2 Post(s)
    Quoted
    4 Post(s)

    Default

    It should be "x := 5;", I think. Why space the second part but not the first?


    Useful links:
    Video how to setup Simba | Send SMS messages via Simba
    Please do not send me a PM asking for help; I will not be able to help you! Post in a relevant thread or make your own! And always remember to search first!

  5. #5
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,787
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

    Default

    Quote Originally Posted by Harry View Post
    It should be "x := 5;", I think. Why space the second part but not the first?
    Actually, I think your right, I assumed the first didn't have a space because that's how I have always done it and there was nothing on the original standard deceleration.

    ~shut

  6. #6
    Join Date
    Oct 2008
    Location
    behind you!
    Posts
    1,646
    Mentioned
    0 Post(s)
    Quoted
    17 Post(s)

    Default

    Quote Originally Posted by Shuttleu View Post
    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!
    Yes
    Simba Code:
    var
      s: string;
      i: Integer;

    begin
      for (i := 0) to 3 do
      Writeln(i);
      if (i = 3) then
        Writeln('i = 3');
      repeat
        Writeln(s);
      until(s = '');
    end;
    No
    Simba Code:
    Var
      s: String;
      i: Integer;

    Begin
      For (i := 0) To 3 Do
      Writeln(i);
      If (i = 3) Then
        Writeln('i = 3');
      Repeat
        Writeln(s);
      Until(s = '');
    End;
    Boooo


    Quote Originally Posted by Shuttleu View Post
    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 theelse clause(s). This improves performance as well as readability.
    Yes
    Simba Code:
    var
      b: Boolean;

    begin
      b := True;
      if b then
        Writeln('b is true')
      else
        Writeln('b is false');
    end;
    No
    Simba Code:
    var
      b: Boolean;

    begin
      b := True;
      if b then
        Writeln('b is false')
      else
        Writeln('b is true');
    end;
    i don't see a difference here... ?



    The rest was great !
    Last edited by Tickyy; 11-29-2010 at 08:31 PM.

  7. #7
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,787
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

  8. #8
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,434
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    When tabing in Simba, it automatically indents two spaces. Much better for people that have coded in different languages.
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

  9. #9
    Join Date
    Jan 2007
    Location
    Stavanger, Norway
    Posts
    8,660
    Mentioned
    107 Post(s)
    Quoted
    255 Post(s)

    Default

    Quote Originally Posted by Shuttleu View Post
    Yes
    Simba Code:
    begin
      Writeln('Hi');
      Writeln('This is indented');
    end;
    No
    Simba Code:
    begin
      Writeln('Hi');
      Writeln('This is not indented');
    end;
    Both of those are intended

  10. #10
    Join Date
    Jan 2010
    Posts
    5,222
    Mentioned
    3 Post(s)
    Quoted
    44 Post(s)

    Default

    PHP Code:
    var
      
    iBoolean;
      
    xInteger;
     
    begin
      
    if(i)then
        Writeln
    ('hi')
      else
        
    repeat
          i 
    := True;
        
    until(i);
      for 
    := 0 to 3 do
        
    Writeln(x);
    end
    PHP Code:
    var
      
    sstring;
      
    iInteger;

    begin
      
    for := 0 to 3 do
      
    Writeln(i);
      if(
    3)then
        Writeln
    ('i = 3');
      
    repeat
        Writeln
    (s);
      
    until('');
    end
    All functions should always return some value. Do not rely on Simba initializing procedure return value automatically!
    Functions will give an error if there is no Result := Something;.

    PHP Code:
    var
      
    xy, [B]x[/B]: Integer
    DTMs will be marked with dtm prefix.
    A suffix will suffice as well.

    Bitmaps will be marked with bmp prefix.
    A suffix will suffice as well.

    PHP Code:
    function TheyAreEqualBoolean;
    begin
      Result 
    := Bool1 or Bool2;
    end
    Your name for the function is contradicting to what it returns.
    23:36 < godzilla> You are the ZIP ZOP BAPPITY ZOOPNEGROX DONGUS WARK ZIP ZOP BAPPITY ZOOPNEGROX DONG US WARK Z IP ZOP BAPPITY ZOOPNEGROX DONGUS WARK ZIP ZOP BAPPITY ZOOPNEGROX DONGUS WARK WARK
    WARK wark wark wark wark wark wark wark wark wark wark WARK WARK WARK WARK WARK WARK WARK WARK BARK WARK WARK WARK WARK WARK
    23:36 < godzilla> WARK WARK WARK WARK WARK WARK WARK WARK WARK WARK WARK.

  11. #11
    Join Date
    Nov 2010
    Location
    Australia
    Posts
    1,469
    Mentioned
    0 Post(s)
    Quoted
    5 Post(s)

    Default

    Quote Originally Posted by Zyt3x View Post
    Both of those are intended
    I see a few people use intended as well. But I thought it was indented, not intended. Correct me if i'm wrong.

  12. #12
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,787
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

    Default

    Quote Originally Posted by i luffs yeww View Post
    PHP Code:
    var
      
    iBoolean;
      
    xInteger;
     
    begin
      
    if(i)then
        Writeln
    ('hi')
      else
        
    repeat
          i 
    := True;
        
    until(i);
      for 
    := 0 to 3 do
        
    Writeln(x);
    end
    PHP Code:
    var
      
    sstring;
      
    iInteger;

    begin
      
    for := 0 to 3 do
      
    Writeln(i);
      if(
    3)then
        Writeln
    ('i = 3');
      
    repeat
        Writeln
    (s);
      
    until('');
    end
    what is wrong with these?
    Quote Originally Posted by i luffs yeww View Post
    Functions will give an error if there is no Result := Something;.
    it wont give a error, it will give a hint and still run

    ~shut

  13. #13
    Join Date
    Jul 2007
    Location
    Norway.
    Posts
    1,955
    Mentioned
    2 Post(s)
    Quoted
    0 Post(s)

    Default

    I find everything in this tutorial to my liking.

    If you also can combine the yes/no's in single code boxes, I'll rep+ you-.
    Really, it just gets too much the way it currently is.

  14. #14
    Join Date
    Jan 2010
    Posts
    5,222
    Mentioned
    3 Post(s)
    Quoted
    44 Post(s)

    Default

    What I posted was a corrected version of what you had. if..then statements are supposed to be if(Whatever)then.
    23:36 < godzilla> You are the ZIP ZOP BAPPITY ZOOPNEGROX DONGUS WARK ZIP ZOP BAPPITY ZOOPNEGROX DONG US WARK Z IP ZOP BAPPITY ZOOPNEGROX DONGUS WARK ZIP ZOP BAPPITY ZOOPNEGROX DONGUS WARK WARK
    WARK wark wark wark wark wark wark wark wark wark wark WARK WARK WARK WARK WARK WARK WARK WARK BARK WARK WARK WARK WARK WARK
    23:36 < godzilla> WARK WARK WARK WARK WARK WARK WARK WARK WARK WARK WARK.

  15. #15
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,787
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

    Default

    Quote Originally Posted by EvilChicken! View Post
    I find everything in this tutorial to my liking.

    If you also can combine the yes/no's in single code boxes, I'll rep+ you-.
    Really, it just gets too much the way it currently is.
    hmmm... how do you propose i combine them?
    any ideas
    or i could do it like this
    Simba Code:
    {YES}
    var
      x: Integer;

    {NO}
    VAR
      x: integer;
    Quote Originally Posted by i luffs yeww View Post
    What I posted was a corrected version of what you had. if..then statements are supposed to be if(Whatever)then.
    i suppose, but i think its better to only have brackets if there is going to be spaces such as "3 = 3" or "not RandomBoolean"
    but if there is going to be one world like "RandomBoolean" or "TehBool" then it shouldnt have brackets
    it seems neater that way

    anyone else agree with me or i luffs yeww?

    ~shut

  16. #16
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,459
    Mentioned
    2 Post(s)
    Quoted
    5 Post(s)

    Default

    I quite like this.

    There'll be a forever argument on standardization, but I think this is a good place to keep the end result of it

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  17. #17
    Join Date
    Jan 2010
    Posts
    5,222
    Mentioned
    3 Post(s)
    Quoted
    44 Post(s)

    Default

    I got that from Kait's site ages ago. I don't care, just saying. I'm sure that site is still archived somewhere.
    23:36 < godzilla> You are the ZIP ZOP BAPPITY ZOOPNEGROX DONGUS WARK ZIP ZOP BAPPITY ZOOPNEGROX DONG US WARK Z IP ZOP BAPPITY ZOOPNEGROX DONGUS WARK ZIP ZOP BAPPITY ZOOPNEGROX DONGUS WARK WARK
    WARK wark wark wark wark wark wark wark wark wark wark WARK WARK WARK WARK WARK WARK WARK WARK BARK WARK WARK WARK WARK WARK
    23:36 < godzilla> WARK WARK WARK WARK WARK WARK WARK WARK WARK WARK WARK.

  18. #18
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,459
    Mentioned
    2 Post(s)
    Quoted
    5 Post(s)

    Default

    Quote Originally Posted by i luffs yeww View Post
    I got that from Kait's site ages ago. I don't care, just saying. I'm sure that site is still archived somewhere.
    Still is, but not written in this form and not on our forums

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  19. #19
    Join Date
    Jan 2010
    Posts
    5,222
    Mentioned
    3 Post(s)
    Quoted
    44 Post(s)

    Default

    RM, do you have a link to it? :3
    23:36 < godzilla> You are the ZIP ZOP BAPPITY ZOOPNEGROX DONGUS WARK ZIP ZOP BAPPITY ZOOPNEGROX DONG US WARK Z IP ZOP BAPPITY ZOOPNEGROX DONGUS WARK ZIP ZOP BAPPITY ZOOPNEGROX DONGUS WARK WARK
    WARK wark wark wark wark wark wark wark wark wark wark WARK WARK WARK WARK WARK WARK WARK WARK BARK WARK WARK WARK WARK WARK
    23:36 < godzilla> WARK WARK WARK WARK WARK WARK WARK WARK WARK WARK WARK.

  20. #20
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,459
    Mentioned
    2 Post(s)
    Quoted
    5 Post(s)

    Default

    Quote Originally Posted by i luffs yeww View Post
    RM, do you have a link to it? :3

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  21. #21
    Join Date
    Jan 2010
    Posts
    5,222
    Mentioned
    3 Post(s)
    Quoted
    44 Post(s)

    Default

    http://www.kaitnieks.com/scar/scriptingsta/

    "if(Condition)then"

    ...

    "if(I = 42)or(J = 42)then"

    Oh. Looks like you got your whole guide from that anyway (almost), so yeah, you should see that it's in there.
    Last edited by i luffs yeww; 12-01-2010 at 12:32 AM.
    23:36 < godzilla> You are the ZIP ZOP BAPPITY ZOOPNEGROX DONGUS WARK ZIP ZOP BAPPITY ZOOPNEGROX DONG US WARK Z IP ZOP BAPPITY ZOOPNEGROX DONGUS WARK ZIP ZOP BAPPITY ZOOPNEGROX DONGUS WARK WARK
    WARK wark wark wark wark wark wark wark wark wark wark WARK WARK WARK WARK WARK WARK WARK WARK BARK WARK WARK WARK WARK WARK
    23:36 < godzilla> WARK WARK WARK WARK WARK WARK WARK WARK WARK WARK WARK.

  22. #22
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,787
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

  23. #23
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,810
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by Nava2 View Post
    I think a new list needs to be created, I'll start with the old ones, editted:

    • Indenting will be two spaces per level. You can indent by selecting text in SCAR and pressing Ctrl+Tab and move backwards by hitting Ctrl+Shift+Tab.
    • Margins will be set to 80 characters. Try not to make too long lines. This is because of general codings standards set by the Unix Terminal.
    • 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. As well, there will be a space between logical operators and conditions in conditional statements.
      Example:
      SCAR Code:
      if ((x = 5) and (y = 5)) then
        DoThis;
    • 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! This means: If its a boolean result, set it to false initially, if its an integer set it to 0/-1, and a string would be ''.
    • Variables will be given names meaningful to their purpose. These names will start with a lowercase letter and be Camel Capped for readability. That includes local and loop control variables, although in this case single character names are acceptable. For loop control variables, try to use the variables: i, j, k, l, and h.
    • 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.
    • For all condition statements, conditions will be encased in a set of parenthesis. This is general coding standard and allows for more obvious reading.
    • 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.
    • All variables, functions, procedures, and constants should be properly commented. One can choose their own style, but use of {} should be put forward over //.
    • Constants Constants should be used as often as possible. This allows for easier readability and self-explanatory code. Constants should be prefixed with a descriptive meaning, usually associated with the File or the Function. They will follow the format: *FILE*_*FUNCTION*_*VALUE*. They will be camel capped, and the *FILE* token can be left out if it is part of a script and only if it a local constant. If the Constant is used globally in a script it will be prefixed with "gbl".


    Comments, ideas?
    My revised copy of the kaitniek's standards.

    Better from the general opinion of the uppers
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  24. #24
    Join Date
    May 2008
    Posts
    1,345
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

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

    BOO!

    Looks good . Except for that. Habit Begin/End ftl(w?).

  25. #25
    Join Date
    Jul 2007
    Location
    Norway.
    Posts
    1,955
    Mentioned
    2 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Shuttleu View Post
    or i could do it like this
    That's a good solution.

    And, I don't know which of you want what, but I think that parentheses should be wrapped around any if-statement. (that is; "if (Bool) then..".)

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •