Results 1 to 15 of 15

Thread: Do i have to free an image thats set to another image?

  1. #1
    Join Date
    Apr 2007
    Location
    California
    Posts
    259
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Do i have to free an image thats set to another image?

    I know it sounds confusing, but if i use
    SCAR Code:
    procedure DTMRocks;
    begin
      case Lowercase(Players[CurrentPlayer].string1) of
        'copper': WhichMMDTM := CopperRockDTM;
        'tin'   : WhichMMDTM := TinRockDTM;
        'iron'  : WhichMMDTM := IronRockDTM;
        'gold'  : WhichMMDTM := GoldRockDTM;
      end;
    end;

    When i finish, do i have to do FreeDTM(WhichMMDTM), or just the ones it gets set to? For instance, let's say string1 is iron, so would i put
    SCAR Code:
    FreeDTM(IronRockDTM);
    FreeDTM(WhichMMDTM);
    or just?
    SCAR Code:
    FreeDTM(IronRockDTM);

  2. #2
    Join Date
    May 2007
    Location
    baltimore, md
    Posts
    836
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    im pretty sure only just iron dtm

  3. #3
    Join Date
    Jul 2006
    Location
    NY
    Posts
    371
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    If you use WhichMDTM to set a DTM, youll only need to free WhichMDTM. Freeing the other DTM's that arent called is pointless.

  4. #4
    Join Date
    Apr 2007
    Location
    California
    Posts
    259
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Okay then i'll do that. If anybody else thinks i have to do both, or is sure that i only have to do one, please let me know

  5. #5
    Join Date
    Apr 2007
    Location
    California
    Posts
    259
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    The other DTMs are called in the beginning though...Well sort of, it uses DDTMs so it's kind of confusing to explain. But basically it's like i called all four DTMs in the beginning of the script and then at the above mentioned part set WhichMMDTM to one of them (to make a certain part of my script work for each one without typing it up four time) and afterwards will need to free ____? I'm pretty sure i need to at least free the four that i called in the very beginning, since i'd need to free them normally..

  6. #6
    Join Date
    May 2007
    Location
    baltimore, md
    Posts
    836
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    just free them when you are completely done using them. it doesnt do much unless you have a slow computer.

  7. #7
    Join Date
    Apr 2007
    Location
    California
    Posts
    259
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Yeah i understand that, i just don't know whether or not to free the WhichMMDTM one since i got two opposite answers now I'm just trying to fix up my script so that it's not 200+ lines longer than it needs to be as someone suggested to me, without altering the way it runs too much hopefully.

  8. #8
    Join Date
    Jul 2006
    Location
    NY
    Posts
    371
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Sorry for posting that, but I was wrong, I edited out to post this. The dtms need to be called in order for them to be set. Just call them once in the begining of the script and dont worry about freeing them.

  9. #9
    Join Date
    Apr 2007
    Location
    California
    Posts
    259
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    While I understand what you're saying i'm not sure how that'd work in my case since i'm using DDTMs. I'll just explain out everything.

    SCAR Code:
    procedure SetRockDTM;
    begin
      case Lowercase(Players[CurrentPlayer].string1) of
        'copper': SetCopperRockDTM;
        'tin'   : SetTinRockDTM;
        'iron'  : SetIronRockDTM;
        'gold'  : SetGoldRockDTM;
      end;
    end;

    That calls the procedure which sets up the DDTM, only one is called.

    SCAR Code:
    procedure FreeRockDTM;
    begin
      case Lowercase(Players[CurrentPlayer].string1) of
        'copper': FreeDTM(CopperRockDTM);
        'tin'   : FreeDTM(TinRockDTM);
        'iron'  : FreeDTM(IronRockDTM);
        'gold'  : FreeDTM(GoldRockDTM);
      end;
    end;

    Frees the same one that gets called, but later on.

    SCAR Code:
    procedure SetWhichImagesAndText;
    begin
      case Lowercase(Players[CurrentPlayer].string1) of
        'copper':
        begin
          WhichMMDTM := CopperRockDTM;
          WhichMMBMP := MMCopperRocks;
          RockText   := 'copper';
        end;
        'tin':
        begin
          WhichMMDTM := TinRockDTM;
          WhichMMBMP := MMTinRocks;
          RockText   := 'tin';
        end;
        'iron':
        begin
          WhichMMDTM := IronRockDTM;
          WhichMMBMP := MMIronRocks;
          RockText   := 'iron';
        end;
        'gold':
        begin
          WhichMMDTM := GoldRockDTM;
          WhichMMBMP := MMGoldRocks;
          RockText   := 'gold';
        end;
      end;
    end;

    Ignore the RockText part, that's something i use later. Now, after i call SetRockDTM i call that, which sets it up for me. Ignore the BMP one for now, i just wanna focus on the DDTM aspect of it. If i used all of the above, would i call FreeDTM(WhichMMDTM) or not?

  10. #10
    Join Date
    May 2006
    Posts
    1,230
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I don't think you'll need to free the DTM's if your going to use them alot in the script. It shouldn't really matter, correct me if im wrong. If you are only going to use the bitmap/DTM once, then you can Free it, but it's not going to make much a different if you keep freeing it and them setting it up again.

  11. #11
    Join Date
    Apr 2007
    Location
    California
    Posts
    259
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Normally i'd agree with you, but being this is a dynamic DTM it's a little different, because the color changes each time so i have to set it just before i use it each time. Basically the color of each subpoint is FindRockColor so it changes each time if that helps explain anything.

  12. #12
    Join Date
    May 2006
    Posts
    1,230
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    before you set it up, put this first. It will free the dtm if it can =p

    SCAR Code:
    try
      FreeDTM(dtmname)
    except
      //no dtm to free
    end;

    the try except end are error handlers.

    try trys to execute the code below it, if it gets an error it will go to except, and end; tells it its the end of except

  13. #13
    Join Date
    Apr 2007
    Location
    California
    Posts
    259
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Wow, i never knew that. I tried that in my script just to test it. Here's what happened. I tried what you said, with this:
    SCAR Code:
    begin
      SetUpSRL;
      LoadImages;
      MMRockColor := 0;
      SetIronRockDTM;
      WhichMMDTM := IronRockDTM;
      try
        FreeDTM(WhichMMDTM);
        Writeln('Yes.');
      except
        Writeln('No.');
      end;
      FreeImages;
    end.

    Returned as yes. Then i tried the same, but changed WhichMMDTM to IronRockDTM, which also returned yes. Then i tried this:
    SCAR Code:
    begin
      SetUpSRL;
      LoadImages;
      MMRockColor := 0;
      SetIronRockDTM;
      WhichMMDTM := IronRockDTM;
      try
        FreeDTM(WhichMMDTM);
        Writeln('Yes.');
      except
        Writeln('No.');
      end;
      try
        FreeDTM(IronRockDTM);
        Writeln('Yes.');
      except
        Writeln('No.');
      end;
      FreeImages;
    end.

    It returned with both yes and no, in that order..This just confuses me. So does that mean i only have to free one of them then?

    [offtopic] First post as an SRL Member [/offtopic]

  14. #14
    Join Date
    May 2006
    Posts
    1,230
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    idk lol. Just don't free them lol. I can't say anything more, idk why the IronRockDTM didn't free
    Did you free the IRONROCKDTM in SetIronRockDTM; function

  15. #15
    Join Date
    Apr 2007
    Location
    California
    Posts
    259
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Nope, it doesn't get freed in there lol. I just made it free only one of them since that seems to always work. Thanks for the help, and for teaching me about try and except

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 14
    Last Post: 06-07-2013, 02:46 AM
  2. Text on top of image?
    By WhoCares357 in forum Web Development
    Replies: 11
    Last Post: 06-11-2008, 09:10 PM
  3. RuneHost - Free Image Hosting
    By jarlaxe in forum Misc. Links and Programs
    Replies: 2
    Last Post: 03-07-2008, 02:10 AM
  4. Whirlpool Image :)
    By Drakan in forum OSR Help
    Replies: 5
    Last Post: 06-13-2007, 05:47 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
  •