Ok, it seems that my brain let me down. I simply can't figure out how to use the instruction. Can you give a concerete example if i need to get the path of file 'graphics.exe'?
Ok, it seems that my brain let me down. I simply can't figure out how to use the instruction. Can you give a concerete example if i need to get the path of file 'graphics.exe'?
Is graphics.exe the executable of your application?
Yes, an executable application has been build when i compiled the program, i presume that should be the executable from which i need to extract the path.
That is correct. Adn you get full finelane (path of your file + filename) of your executable with
Code:Application.ExeName
Am i doing it wrong or... i tried to use what you told me below and got this
I know it's wrong, but with what should i replace that to make it work?Code:path:=pChar(ExtractFilePath(grafica.exeName));
Ahh now I see what is confusing you.
When I write use Application.ExeName I mean that literally.
You see in modern pascal dialects the Application is actually a global variable for TApplication class which contains several properties and methods. Best example of seeing this in use is looking ath the source of your project file (*.dpr file).
And one of its properties is ExeName which contains full filename of your application executable.
With Freepascal you can also use the "old school" way:
(No need for pChar as you can see.)Code:path:=ExtractFilePath(ParamStr(0));
Best regards,
Cybermonkey
Ok, in the end i mananged to find out how to make it work with paths, thanks to both of you
Another question: I've heard from my teacher that in the Pascal IDE are some options or something like that to show the amount of memory and time execution of a program. Can you tell me how to make use of them?
For which operating system do you compile your program? For windows or linux?
About the amount of memory, you should definately be able to get information from the memory manager about the allocated memory size. But when you use external libraries usually they allocate memory using their own memory managers so you cannot catch their memory usage. If you need to monitor you program's memory usage and track for memory leaks and your program is running on windows, i can definately advise you to try this program - VMMap. It can monitor the memory blocks your process has allocated, and it can trace the call stack of each allocation.
About performance, you could measure execution time of your whole program or separate procedures very easily. For example if you want to measure how much time does it take to execute procedure called DoSomething(), then you can do like this:
Code:var T: Int64; begin T := GetTickCount; DoSomething(); T := GetTickCount - T; //Now variable T will hold the execution time of your procedure in milisecond units. //Output this value somewhere you can see it. End;
@Anton
As far as I know the TickCount can be updated more than once per ms. I think that many newer computer already update tckCount every half millisecond.
This means that variable T in your suggested code might not represent time taken in ms. Now it is possible to retrieve information from OS to see how often is TickCount updated so you can then properly calculate the time taken.
Newer versions of Delphi also provides a special record called TStopWatch which tries to use the approach with best percision that is available on your computer. I have use it several times now for time profiling.
But most of the times I simply go and store a time at the start of the process and another at the end and then check how much millisceconds did pas between them.
Now you would probably say SilverWarior that approach doesn't provide good enough accuracy.
That usually doesen't present a problem to me becouse if posible I tend to repeat certain procedure multiple times and check how much time is taken for that.
Why am I doing so? Nowadays all computer support CPU autothrotling which can affect the test performance. Not to mention that you always have bunch of other processes running in the background which can consume veriable amounts of CPU power and greatly screw up your tests.
Bookmarks