SRL Archive - Help and Support

How to UnImport an* Imported Include?


Sir Ducksworthy

2012-06-25 07:07:15

I'm working on a new project right and since I have a nasty habit of using a lot of recursion when coding, I found my self getting stuck in really odd loops and stuff sometimes n it would drive me mad although its better then cycling so much.

The project is massive its going to be at least 10k Lines Long I'm guessing by the time I've completed the F2P Version

So what I've done basically Is use a .net file to record all of the data and read it all so it knows where it is up 2 and everything.

It will be using multiple skills and lot's of code, so I've also made an Include to handle the recursion part of it plus lessen the Cpu usage and stuff.
I can then Import seperate Includes seperate scripts and stuff so it doesn't need to cycle through so many lines and the Include will take over what I want to be able to do is free these Includes from the memory

Echo_

2012-06-25 08:26:59

I don't think you can do this because the text from the included file is inserted into the script as a string before compilation. At runtime it's there to stay.

Jakkle

2012-06-25 08:53:28

You could case the things you want to use so it will only go through the code you've specified. Like loading var's when a player is at a location.
I think I know what your project is :p
Anything to do with the new 14 day trial accounts by any chance ?
:sasmokin:

Sir Ducksworthy

2012-06-25 09:41:40

Oo righto, the way I'm gonna try and do it now is just to use a .net to load any required code into a stringarray.
So I'll be able to free it properly

Nah nothing 2 do with Trial Acc's really, although you just made me very curious as to what you had in mind XD.

Another question:
Would Casing things take time to go through the lines to find the text or would it be much faster to Load say 20 Procedures/Functions into a String Array then freeing them so it only has to read through 200 Lines instead of 1000 or something that would probably end up being cached.

Brandon

2012-06-25 09:51:13

When you include a file it's basically telling a compiler to copy paste everything from it and put it where the include was called. Either way, all the code from the include will be imported.

How you use and call that code is a totally different story. If you're going to be loading a DTM that's going to be used like 50m times during a loop or the entire script, you're not going to want to load it and free it and load it and free it. It makes sense to load it once and free it at the end of your script.

Loading it till the end has it's consequences: It can spike you and keep you spiked. Meaning it can use up memory and keep the memory usage high but CPU may go back to normal.

Loading and freeing also has it's consequences: It can introduce a fake lag. Every load can be intensive and spike you up then freeing will release it and make it go down. Another load and free will do the same thing. Your CPU may or may not go back to normal since it will be working to load and free but your memory will go normal every free.

Case statements are ok depending on how you use them. I'd probably load all at once and addonterminate a free procedure. Not sure what you mean by load functions into a string array unless you mean some other language.

Sir Ducksworthy

2012-06-25 10:15:36

Interesting stuff man,
O what I meant is using ReadIni to Load Each Procedure/Function into a Global TStringArray, from a .net file or .ini < but I've only been able to get .net's to work for some reason and then just calling each string with that CallProc function and then Freeing the text in each Individual String by setting it back to '' but not all at once so it doesn't make it mess up so much.

Brandon

2012-06-25 10:23:02

Hmm Loading via CallProc doesn't allow freeing unless you callproc a function that frees.


{$I SRL/SRL.Simba}
{$I Useful.Simba} //Contains procedure Meh;

var
V: TVariantArray;
Proc: string;

begin
SetupSRL;

Proc:= ReadINI('Functions', 'Meh', IncludesPath + 'Useful.INI');

CallProc(Proc, V);
Proc:= ''; //Does not free anything that Meh loads. This just makes a string size 0. aka \0 null terminated.

CallProc('FreeMeh', V);
end.

Also since the file is included, it's just better to directly call the functions inside it rather than callproc because No matter what, you have to include the file. No way to callproc a function that isn't part of the script.

Sir Ducksworthy

2012-06-25 10:58:34

Hmm.. It'd really be awesome if their was a way to call a procedure inside of a String since CallProc only calls the procedures name so the procedure would need to be in the script or in an Include so it wouldn't work, O mann..
Thx for your help hey bros


SetLength(Procedures,5);
Procedures[0]:=ReadIni(Procedures, Mehh lol, 'core.net');
Procedures[1]:=ReadIni(Procedures, Mehh lol, 'core.net');
Procedures[2]:=ReadIni(Procedures, Mehh lol, 'core.net');
Procedures[3]:=ReadIni(Procedures, Mehh lol, 'core.net');
Procedures[4]:=ReadIni(Procedures, Mehh lol, 'core.net');
Procedures[5]:=ReadIni(Procedures, Mehh lol, 'core.net');
CallProc(Procedures[0], V]);
Procedures[0]:='';