Results 1 to 14 of 14

Thread: DTM as Constant

  1. #1
    Join Date
    Sep 2007
    Posts
    73
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default DTM as Constant

    Can I use DTM as a constant

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

    Default

    Hmm no clue, but what do you mean, why would you want to do that for?

  3. #3
    Join Date
    Sep 2007
    Posts
    73
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I want to use DTM in my main block as well as some function where do I initialize it

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

    Default

    Quote Originally Posted by astoria1112000 View Post
    Can I use DTM as a constant
    Quote Originally Posted by astoria1112000 View Post
    I want to use DTM in my main block as well as some function where do I initialize it
    You mean that you only want to initialize it once so that you can use it everywhere? Then declare it as a global variable. Eg:
    Simba Code:
    program new;
    //include srl here

    var
      dtmstring: string;  //<<< global variable when declared outside other functions/procs
      DTM: Integer;       //<<< global variable when declared outside other functions/procs

    procedure blahbla;
    begin
    end;

    procedure somemoreblaaaa;
    begin
    end;

    procedure MainLoop;
    begin
      DTM := DTMFromString(dtmstring);//initialize dtm at start of script once!
      //dtmstring is the funny string you get: 'CBVnaldsfghiolasndg+asdklans564351'
      blahbla;
      somemoreblaaaa;
    end;

    begin
      //SetupSRL;
      MainLoop;
    end.

  5. #5
    Join Date
    Sep 2007
    Posts
    73
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    wait if it doesnt work now, i will post my code here

    Look at this and tell me if its fine

    While(True) do
    Begin

    DTM := DTMFromString('......');
    if FindDTM(DTM, x, y,.....) then
    .....

    FreeDTM(DTM);
    End;
    Last edited by astoria1112000; 12-01-2011 at 09:16 AM.

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

    Default

    You want to put the BEFORE the while loop
    like this
    DTM := DTMFromString('......');
    While (True) Do

    That way it's only loaded once! Not over and over

  7. #7
    Join Date
    Sep 2007
    Posts
    73
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    What does FreeDTM(DTM) do... Do i need to reinitialize the DTM to use it again

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

    Default

    Quote Originally Posted by astoria1112000 View Post
    What does FreeDTM(DTM) do... Do i need to reinitialize the DTM to use it again
    FreeDTM reallocates/removes the memory that was used to store the DTM so that your script uses less RAM(or cpu?). And yes if you freedtm you have to do dtm := dtmfromstring() again if you want to use it.

    Note: The less times you load/unload the better it is in terms of memory management.

  9. #9
    Join Date
    Sep 2007
    Posts
    73
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    So how can I do it if I need to use DTM inside my WHILE LOOP without loading and unloading it inside my loop

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

    Default

    Simba Code:
    LoadDTM
    While (Ture) Do
    Begin
      Stuff
      If FindDTM Then
      Stuff
    End;
    FreeDTM;

    Like that

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

    Default

    Quote Originally Posted by astoria1112000 View Post
    So how can I do it if I need to use DTM inside my WHILE LOOP without loading and unloading it inside my loop
    load it before starting the loop and unload it after the loop.

    E: Damn ninja'd by YoHoJo

  12. #12
    Join Date
    Sep 2007
    Posts
    73
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I terminate my script manually so is there a way to FreeDTM when I stop the script (Clicking RED STOP button)

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

    Default

    Quote Originally Posted by astoria1112000 View Post
    I terminate my script manually so is there a way to FreeDTM when I stop the script (Clicking RED STOP button)
    I think its automatically freed. But you can do this:
    Simba Code:
    AddOnTerminate('name_of_procedure_or_function');

    put the freedtm in a procedure and call addonterminate at the start of the script. That way the dtm will be freed for sure.

    Note: You have to include srl to use addonterminate.

  14. #14
    Join Date
    Sep 2007
    Posts
    73
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thank you guys for your help, Script 90% done

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
  •