Can I use DTM as a constant
Can I use DTM as a constant
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.
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.
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![]()
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.
So how can I do it if I need to use DTM inside my WHILE LOOP without loading and unloading it inside my loop
Simba Code:LoadDTM
While (Ture) Do
Begin
Stuff
If FindDTM Then
Stuff
End;
FreeDTM;
Like that
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.
Thank you guys for your help, Script 90% done
There are currently 1 users browsing this thread. (0 members and 1 guests)