Results 1 to 10 of 10

Thread: Constant Arrays

  1. #1
    Join Date
    Aug 2007
    Location
    Emo-land
    Posts
    1,109
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Constant Arrays

    Just wondering if you can make an array with constants? Something like

    SCAR Code:
    const
      t[0] = 0
      t[1] = 1
      t[2] = 2
      t[3] = 4
      t[4] = 16

    If anyone knows if that or anything will work please drop a line

  2. #2
    Join Date
    Feb 2007
    Location
    Het ademt zwaar en moedeloos vannacht.
    Posts
    7,211
    Mentioned
    26 Post(s)
    Quoted
    72 Post(s)

    Default

    Not possible with scar.
    However, you can create a global var, the just load it in the beginning of the script like this:
    SCAR Code:
    TheArr := [1, 2, 6, 4, 23424, 42342];
    As long as you don't touch it, it shouldn't matter if it's a var/const
    I made a new script, check it out!.

  3. #3
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    or if you want the user to change those consts just do a procedure at the beginning of the script
    SCAR Code:
    procedure ConstantArray;
    begin
      Const[0] := 's';
      Const[1] := 'a';
      Const[2] := 'p';
    end;

    then call the proc at the beginning of the mainloop.

    RM

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

  4. #4
    Join Date
    Jun 2007
    Posts
    785
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    dude you are calling consts in them middle of a procedure? shame yourself!

    [22:20] <[-jesus-]> freddy, go uninstall yourself

  5. #5
    Join Date
    Aug 2007
    Location
    Emo-land
    Posts
    1,109
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Darn I was just hoping that I could to save on memory and time of using it? Because I have Path[0] to Path[4], and they are always the same so I wanted to constant. Oh well.

  6. #6
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    Quote Originally Posted by Dumpin View Post
    dude you are calling consts in them middle of a procedure? shame yourself!
    Maybe not in the middle, but in the beginning

    SCAR Code:
    Procedure WWait(Const Time: Integer);
    Begin
      Wait(Time);
    End;


    Rasta... Your... Thingie, does not work.

  7. #7
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Why not do this.

    SCAR Code:
    Const

    Path[0] =
    Path[1] =
    Path[2] =
    Path[3] =
    Path[4] =

    Var
    Constant : Array[0..7] of integer;

    Begin
    For i := 0 to 4 do
    Constant[i] := Path[i];

    End.

    Dunno, didn't really try that before tho..

    Edit: Nevermind didnt work you get

    SCAR Code:
    Line 6: [Error] (12585:5): is ('=') expected in script

    So maybe ask freddy to add that hmm....?

  8. #8
    Join Date
    Aug 2007
    Location
    Emo-land
    Posts
    1,109
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    No and besides that destroys the whole point of using constants instead of variables, in fact it uses more memory lol.

  9. #9
    Join Date
    Dec 2006
    Location
    utah
    Posts
    1,427
    Mentioned
    2 Post(s)
    Quoted
    7 Post(s)

    Default

    Only In Delphi

    SCAR Code:
    const
           C: array [0..2] of Integer = (1, 2, 3);

    i believe that's how it's done..
    Co Founder of https://www.tagcandy.com

  10. #10
    Join Date
    Aug 2007
    Location
    Emo-land
    Posts
    1,109
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SKy is a master! TYVM lol you are da man!

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Arrays, stuck on arrays
    By Camaro' in forum OSR Help
    Replies: 1
    Last Post: 03-08-2008, 02:02 AM
  2. Constant logging out.
    By Wade007 in forum OSR Help
    Replies: 14
    Last Post: 02-25-2008, 11:36 PM

Posting Permissions

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