Results 1 to 22 of 22

Thread: Sup with this?

  1. #1
    Join Date
    Dec 2011
    Location
    Toronto, Ontario
    Posts
    6,424
    Mentioned
    84 Post(s)
    Quoted
    863 Post(s)

    Default Sup with this?

    Simba Code:
    type
    Ore = record
      Col,Tol:Integer;
      Name:String;
      HMod,SMod:Extended;
    end;
    Simba Code:
    var
      Ores:array of Ore;


    with Ores[0] do
      begin
        Col := 2568527;
        Tol  := 11;
        HMod := 0.05;
        SMod := 0.62;
        Name := 'Iron';
      end;

    SRL Compiled in 0 msec
    Paired with SMART[4592]
    Error: Out Of Range at line 48
    The following DTMs were not freed: [SRL - Lamp bitmap, 1]
    The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap, SRL - Flag bitmap, SRL - NavBar Bitmap]



    I'm clueless at what's going on :s

  2. #2
    Join Date
    Nov 2010
    Location
    Australia
    Posts
    1,472
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    you need to use setlength or use ores := [toOre(...)]

  3. #3
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Bro you know better.
    Post the entire script or at least tell us what line 48 is if you want to be a secretive noob.

    My guess is maybe just maybe you need to set the length first? I'm not too great with types.

  4. #4
    Join Date
    Dec 2011
    Location
    Holland
    Posts
    545
    Mentioned
    0 Post(s)
    Quoted
    19 Post(s)

    Default

    array [0..10] of ore;

    That's my guess

  5. #5
    Join Date
    Dec 2011
    Location
    Toronto, Ontario
    Posts
    6,424
    Mentioned
    84 Post(s)
    Quoted
    863 Post(s)

    Default

    Quote Originally Posted by KingKong View Post
    you need to use setlength or use ores := [toOre(...)]
    Quote Originally Posted by YoHoJo View Post
    Bro you know better.
    Post the entire script or at least tell us what line 48 is if you want to be a secretive noob.

    My guess is maybe just maybe you need to set the length first? I'm not too great with types.
    SetLength worked, thanks!

  6. #6
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Man SRL rocks! This community is great.

  7. #7
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    It is very important to understand the principle why you have to set the length of an array. It will teach you a bit about memory and how to use it. This is important because in Lape there isn't any check for array length and you will just get a value random from you memory, or even worse you set the value of a random piece of your memory.

    Image your memory as a cupboard without drawers. When you create a variable you will create a drawer with the exact size of what you want to put in the drawer and if there is still space in the cupboard you will place it there. The variable you use in your script is a reference to that drawer. For a integer this drawer is exactly 32 bits big. Or a Byte which is 8 bits. And a Boolean which is 1 bit.

    When you create your own type you will go full hardcore engineer mode. You will design your own custom drawer. You will only create the building plans of the drawer, not the drawer itself. So if you want to use it you will still have to create it.



    type Dog = record //Creating the building plan
    size, smell, gender: Integer;
    end;

    var a: Dog; //Creating the drawer and placing it in the cupboard

    a.size := 5; //Putting stuff in the drawer
    a.smell := 99999;
    a.gender := -1;

    An array is harder, how big is that drawer? Well that depends of course, how much you want to put into it. So a few tricks were created. Now I will only discuss one. You start with creating an array drawer. This drawer basically contains; "The following x drawers have the size of typeX".

    var b: Array of Dog;

    Note that there still isn't any drawer to store your dogs in. That variable doesn't contain any dogs. So to make use of it we have to create dog drawers like we did before. Let's say we got four dogs.

    setLength(b, 4); // Creating four dog drawers

    b[0].size = 3; //Putting stuff in the drawers
    b[0].smell := 9999;

    etc...

    Now when you call b[0] you will look into drawer b, which tells where to find the correct drawer. If you didn't set the Length it will give an error in pascalscript, in Lape it will give you a random drawer out of your memory, that can contain anything. This is dangerous if you put random stuff in it, simba could crash.
    Working on: Tithe Farmer

  8. #8
    Join Date
    Dec 2011
    Location
    Toronto, Ontario
    Posts
    6,424
    Mentioned
    84 Post(s)
    Quoted
    863 Post(s)

    Default

    Quote Originally Posted by masterBB View Post
    It is very important to understand the principle why you have to set the length of an array. It will teach you a bit about memory and how to use it. This is important because in Lape there isn't any check for array length and you will just get a value random from you memory, or even worse you set the value of a random piece of your memory.

    Image your memory as a cupboard without drawers. When you create a variable you will create a drawer with the exact size of what you want to put in the drawer and if there is still space in the cupboard you will place it there. The variable you use in your script is a reference to that drawer. For a integer this drawer is exactly 32 bits big. Or a Byte which is 8 bits. And a Boolean which is 1 bit.

    When you create your own type you will go full hardcore engineer mode. You will design your own custom drawer. You will only create the building plans of the drawer, not the drawer itself. So if you want to use it you will still have to create it.



    type Dog = record //Creating the building plan
    size, smell, gender: Integer;
    end;

    var a: Dog; //Creating the drawer and placing it in the cupboard

    a.size := 5; //Putting stuff in the drawer
    a.smell := 99999;
    a.gender := -1;

    An array is harder, how big is that drawer? Well that depends of course, how much you want to put into it. So a few tricks were created. Now I will only discuss one. You start with creating an array drawer. This drawer basically contains; "The following x drawers have the size of typeX".

    var b: Array of Dog;

    Note that there still isn't any drawer to store your dogs in. That variable doesn't contain any dogs. So to make use of it we have to create dog drawers like we did before. Let's say we got four dogs.

    setLength(b, 4); // Creating four dog drawers

    b[0].size = 3; //Putting stuff in the drawers
    b[0].smell := 9999;

    etc...

    Now when you call b[0] you will look into drawer b, which tells where to find the correct drawer. If you didn't set the Length it will give an error in pascalscript, in Lape it will give you a random drawer out of your memory, that can contain anything. This is dangerous if you put random stuff in it, simba could crash.
    Thanks! I was getting an error when I was calling an array inside an array, and this sorta cleared it up

  9. #9
    Join Date
    Dec 2011
    Location
    Nj
    Posts
    2,341
    Mentioned
    1 Post(s)
    Quoted
    18 Post(s)

    Default

    Quote Originally Posted by YoHoJo View Post
    Man SRL rocks! This community is great.
    I feel an unintended pun
    Rocks...Ores...
    ~Rez

    For the basics of the basics of pascal, try my TuT. ||Photoshop Editing ||MapleResourceDung Script || Book a flight! BuySellTrip

  10. #10
    Join Date
    Dec 2007
    Posts
    2,112
    Mentioned
    71 Post(s)
    Quoted
    580 Post(s)

    Default

    Quote Originally Posted by Rezozo View Post
    I feel an unintended pun
    Rocks...Ores...
    ~Rez
    I feel an SRL Member should have known better -.-
    FML seriously tho? out of range error? how many other ways can you get that?

  11. #11
    Join Date
    May 2007
    Posts
    527
    Mentioned
    12 Post(s)
    Quoted
    109 Post(s)

    Default

    Quote Originally Posted by Kasi View Post
    I feel an SRL Member should have known better -.-
    FML seriously tho? out of range error? how many other ways can you get that?
    My thoughts exactly. These are basic stuff...

  12. #12
    Join Date
    Dec 2011
    Location
    Toronto, Ontario
    Posts
    6,424
    Mentioned
    84 Post(s)
    Quoted
    863 Post(s)

    Default

    Quote Originally Posted by Kasi View Post
    I feel an SRL Member should have known better -.-
    FML seriously tho? out of range error? how many other ways can you get that?
    4 AM in the morning mate, when I just woke up with nothing better to do.

  13. #13
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Why ya'll being so mean?! Everyone has brain farts sometimes!

  14. #14
    Join Date
    Oct 2008
    Location
    C:\Simba\Includes\
    Posts
    7,566
    Mentioned
    19 Post(s)
    Quoted
    180 Post(s)

    Default

    I never have brain farts, because I am awesome.
    Away for awhile, life is keeping me busy. | Want to get my attention in a thread? @Kyle Undefined; me.
    { MSI Phoenix || SRL Stats Sigs || Paste || Scripts || Quotes || Graphics }

    When posting a bug, please post debug! Help us, help you!

    I would love to change the world, but they won't give me the source code. || To be the best, you've got to beat the rest. || Logic never changes, just the syntax.
    If you PM me with a stupid question or one listed in FAQ, or about a script that is not mine, I will NOT respond.


    SRL is a Library of routines made by the SRL community written for the Program Simba. We produce Scripts for the game Runescape.


  15. #15
    Join Date
    May 2007
    Posts
    527
    Mentioned
    12 Post(s)
    Quoted
    109 Post(s)

    Default

    I usually have arsefarts, in public places..

    E:

    I'm traumatized.

  16. #16
    Join Date
    Dec 2011
    Location
    Hyrule
    Posts
    8,662
    Mentioned
    179 Post(s)
    Quoted
    1870 Post(s)

  17. #17
    Join Date
    May 2007
    Posts
    527
    Mentioned
    12 Post(s)
    Quoted
    109 Post(s)

    Default

    Quote Originally Posted by Ashaman88 View Post
    No need to hate, why not try to help instead?

    Awesome explanation masterbb!
    No hate here, only pondering..

  18. #18
    Join Date
    Dec 2011
    Location
    Nj
    Posts
    2,341
    Mentioned
    1 Post(s)
    Quoted
    18 Post(s)

    Default

    The pondering hurts JK
    ~Rez

    For the basics of the basics of pascal, try my TuT. ||Photoshop Editing ||MapleResourceDung Script || Book a flight! BuySellTrip

  19. #19
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    Don't feel superior above other just because there is one basic thing you knew he didn't. That doesn't equal you know more then the other. Learning is a process of gathering information and understanding it. This is usually randomly grabbing pieces which you require on your task. It happens often that you miss one thing that most of the others didn't miss.
    Working on: Tithe Farmer

  20. #20
    Join Date
    Dec 2007
    Posts
    2,112
    Mentioned
    71 Post(s)
    Quoted
    580 Post(s)

    Default

    Quote Originally Posted by Kyle Undefined View Post
    I never have brain farts, because I am awesome.
    just narcissistic

  21. #21
    Join Date
    Feb 2007
    Location
    PA, USA
    Posts
    5,240
    Mentioned
    36 Post(s)
    Quoted
    496 Post(s)

    Default

    Quote Originally Posted by Kyle Undefined View Post
    I never have brain farts, because I am awesome.
    true story.
    @s1n, come on bro, out of range...

  22. #22
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Spamfest.
    Closed.

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
  •