When I start a program in the IDE, I use the following code to generate a log file. All of the paths are correct, checked with F8, but the log file is not output.
When I run the executable outside of the IDE, the log file is output properly.
Is there a setting somewhere in XE7 that prohibits this?
procedure LogProgram(const aEvent: String);
var
TheLogFileName, TheLogLine: String;
TheLogFile: TextFile;
TheDay, TheMonth, TheYear, TheHour, TheMinute, TheSecond,
TheMilliSecond: Word;
begin
TheLogFileName := Format('%s%d.log', [usPATH_LOGS, Trunc(Now)]);
AssignFile(TheLogFile, TheLogFileName);
if not FileExists(TheLogFileName) then
Rewrite(TheLogFile);
Append(TheLogFile);
DecodeDateTime(Now, TheYear, TheMonth, TheDay, TheHour, TheMinute, TheSecond,
TheMilliSecond);
TheLogLine := Format('%d-%d-%d: %d:%d:%d:%d%s%s', [TheYear, TheMonth, TheDay,
TheHour, TheMinute, TheSecond, TheMilliSecond, #9, aEvent]);
Writeln(TheLogFile, TheLogLine);
CloseFile(TheLogFile);
end;
I tried to output a file, using the above code, while a program was running in the Delphi XE7 IDE, expected a log (text) file and got no output. Running the same program outside of the IDE generates the log (text) file properly.
#fpiette I checked Windows Security and folder protection is not active.
#Andreas-Rejbrand I'm using relative paths. Paths are being calculated relative to the path of the executable
#SilverWarior I did not change anything in Delphi through menu Run->Parameters. There are no paths listed there.
I did a global search (on my computer) for the name of the file, I was trying to create and discovered it in a containment folder (c:\VTRoot) managed by Comodo antivirus.
It turned out that if Comodo thought the file being created was a security risk, it moved it to the containment area on C:\
I went to the Comodo dashboard and disabled Auto-Containment and now Delphi XE7 works as it should.
The first, click button1,can get the [section].[Key].Value
but if change the path via the second page's [...] of PromptDataSource()
Then the next time, click button1, can not get the [section].[Key].Value
Why???
Awe.dat
[Options]
DBConnection=Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=D:\2000.mdb;
the Button1Click's code
procedure TForm1.Button1Click(Sender: TObject);
var
Filename:string;
DatFile:TiniFile;
str:WideString;
ConnectStr:WideString;
begin
DatFile:=Tinifile.Create('.\Awe.dat');
str:=DatFile.ReadString('Options','DBConnection','');
ShowMessage(str+'-----------------');
ConnectStr:=PromptDataSource(handle,str);
ShowMessage(str+'-----------------'+ConnectStr);
DatFile.Free;
end;
It seems that the problem is related to your use of a relative path. Your path is relative to the process working directory.
If the working directory is in your complete control then your code would be fine. But often the working directory is not in your complete control. The process may start with an unexpected working directory. File dialogs may change the working directory.
You are better being explicit and providing a full path to the file. It looks like your file is in the same directory as the executable. So you could use:
ExtractFilePath(Application.ExeName) + FileName
or similar.
Hi as the title says i want to know what code i should use and how i would go about setting up my program so that when i drag a file over a panel or the main form,
It gives me the file path of that folder.
Please Help.
It's as simple as this:
Put a TDropTarget component on the main form.
Set the Filter property. Put * instead of . if you want it to accept folders as well as files.
In the OnDropped event, the list of fully qualified file and or folder names is in Data.Files. You should be able to get everything you need from there.
Is this what you are trying to accomplish, or do you have something else in mind?
Update:
By request, added an example that shows the name of the first file that was dropped.
procedure TForm1.DropTarget1Dropped(Sender: TObject; const Data: TDragObject;
const Point: TPointF);
begin
ShowMessage(Data.Files[0]);
end;
I want to use KOL to make very small Exe.
Everything is seems to be ok, but I don't know how to set the main icon of the application (in the taskbar).
Add an icon resource to your project with the icon name being MAINICON.
So, in your .rc file you have this:
MAINICON ICON "MyAppIcon.ico"
And in the .dpr file compile and link the resource like this:
{$R 'MyApp.res' 'MyApp.rc'}
If you have an older version of Delphi that won't accept this syntax for $R then you'll need to compile the resource manually and link it like so:
{$R 'MyApp.res'}
For example, this .dpr file:
uses
KOL;
{$R 'MyApp.res'}
var
Form: PControl;
begin
Form := NewForm(nil, 'My form');
Run(Form);
end.
is all you need to create an app with a main form having an icon, and that icon being shown on the task bar.
And here's what it looks like:
Note that some of the KOL demo projects have code like this:
Form.Icon := THandle(-1);
which naturally interferes with any attempts to impose an icon. Clearly you'll need to remove any such code. I struggled with this a little whilst answering this question (my first ever KOL project FWIW) and wonder if you might have the same problem.
In Delphi 7 whenever I control+clicked a function/procedure it took me to that function/procedure. But it is not working in Delphi XE - at least not with all functions. I have a function called Associate in ExtUtils.pas
The function is correctly compiled so the compiler can find the ExtUtils.pas (and of course the ExtUtils is added to the Uses clause and its folder its added in 'Library path'). But when I control+click the function or the unit name, it doesn't take me there.
Any way to fix this?
UPDATE1:
Also, Control+Click on a function (declare in the current unit) does not move the cursor in the INTERFACE section where the function is declared.
UPDATE2:
I temporary put the ExtUtils unit in project's folder and now it works. So, the Control+Click by itself it works but it seems that the IDE has problems finding the unit even it its folder is present in Library Path and Browsing Path.
Similar reports:
http://webcache.googleusercontent.com
http://webcache.googleusercontent.com
http://cc.embarcadero.com/Item/28269
One report right here (see answers below)
New test:
I have fully uninstalled Delphi (and manually delete the files and registry leftovers). Then reinstalled again. NO additional tools except CodeSite were installed, not even the databases. Then I created a new project. It contains a button. When I click the button, it runs the TestMe procedure which is defined in an external PAS file called TestUnit.Pas. I added the path to this library in Library Path and Browsing Path. But the Control+Click on TestMe procedure is still not working! If I hover the mouse over the TestMe procedure, the pop-up says "Declared in TestUnit", where the 'TestUnit' word is a blue link. If I click it I hear a Windows system sound but the IDE doesn't take me there (to the unit).
The TestMe procedure is this:
procedure TestMe;
begin
Beep(800, 500);
end;
If I control+click the Beep procedure, it takes me to Windows.pas. So, this is working.
Please let me know if you have in mind a different test.
UPDATE:
And now it works! Without any apparent reasons! I just open and closed and compiled the project. But I make no changes to Delphi except these two: AutoSave options-> Editor files and Project Options.
UPDATE:
This cannot be!!!
So, now I can access the TestUnit.pas file when I control+click on TestMe procedure.
So, I moved the original PAS file (ExtUtils.pas) that didn't wanted to work in my initial test (before Delphi reinstall) in the same folder where TestUnit.pas is. Guess what: I can open (with control+click) to TestUnit.pas but not the ExtUtils.pas!!!!
Delphi acts so strange and inconsistent!
UPDATE:
I edited ExtUtils.pas and now I cannot open AGAIN TestUnit.pas.
Ken White won't let me say that Delphi could possible have bugs. So I cannot use the 'bug' together with 'Delphi'. Can anybody put these words together for me?
UPDATE:
I totally removed any reference to ExtUtils.pas - so I restored the project to the point where it worked (with TestUnit). But now the bug persists. Even if few seconds before it worked with TestUnit now its not working again.
UPDATE:
Now I realize an important thing: in my source code (in the test project) I have a single line of compilable code:
procedure TForm1.Button1Click(Sender: TObject);
begin
TestMe;
end;
The blue dots does not appear for this code - as it wouldn't have been compiled. In those few minutes when the program worked, I have seen the blue dots.
I have also excluded 'AutoSave options-> Editor files and Project Options' as a possible cause for this issue.
UPDATE:
I have found a way to fix the problem... for few minutes: I move the project and the library in a different folder (any location will do it). The control+click will work for a while. It even works if I put the files back into the original folder. So, it seems that Delphi keeps some kind of cache of some files. As long as the cache is broken and it keeps the cache, control+click won;t work. But when I move the files, it has to recreate that cache so it will work until the issue reappears and it is stored in the cache.
Here we are 5 developers using Delphi 2010 and 2 also using XE and we are experiencing the same thing with the Ctrl-click as you. It seems to stop working randomly. We never could find a pattern or a fix for that. So from time to time we hear swearing coming from cubicles...
When that happens, I use shift-ctrl-F, to do a search.
Sylvain
First, thanks for you all to give hints about this problem. Maybe this is a question long time ago, but at last, after tried many many times, I think the problem cause is, actually, in the "project source code"
IDE version: Delphi XE
please try:
in the Project Options >> Delphi Compiler>>Compiling , ensure:
Debug Information: true
Symbol Reference Info: Reference info
in the Project Source file(dpk file, open by Project >> View Source),
remove {$REFERENCEINFO OFF}
or change to {$REFERENCEINFO ON}
Note that step 2 is very important, even step 1 done, it still can not browse source without step 2.
I'm using Delphi 5 and the Ctrl-click have also problems, i don't know if it still working in the new delphi IDEs but i can go from declaration to implementation using CTRL-SHIFT-UpArrow or DownArrow.
Hope it helps.
There have always been these two distinct options in Delphi:
Library path – used when compiling your app.
Browsing path – used by Code Insight, i.e. when control-clicking identifiers too.
You need to check the second one. It must include the path(s) to the source files you are trying to navigate with Ctrl+Click.
I've found that if I use a record type in the interface section and it's not defined by a type expression, Ctrl-Click and other jumping functions (Ctrl+Shift+Up/Down) won't work.
type
TForm1 = class(TForm)
...
public
Something:record
A, B:integer;
end;
procedure DoSomething;
end;
With the code above I can't jump to implementation of the procedure with Ctrl+Shift+Down. The fix I have to use:
type
TMyRecord = record
A, B:integer;
end;
TForm1 = class(TForm)
...
public
Something:TMyRecord;
procedure DoSomething;
end;
Tested with Delphi XE4.
For future reference. Using Delphi 2010 i have found that a ; preceding virtual in the interface section makes a difference;
function MyProc(): String; overload; virtual;
function MyProc(): Integer; overload; virtual;
// >> ^ <<
This ; character can break the CTRL+Click (code insight) functionality. Compiles fine nonetheless.
I had just made a new groupproject with two projects in Delphi 11. After that I was having problem using Ctrl + Click to jump to functions. I right clicked the groupproject and did "Clean All" and then "Build All" after that it was working for me again.
(Symbol Reference info)This option has no effect unless Debug information and Local symbols (see above) are enabled.
Code completion and code navigation features (Ctrl+Click) work only when Symbol Reference info is set to Reference info.
Solved!
It works for me, change the Code Insight type.
This happens to me quite often, specially when two IDE is opened at the same time.
The way I have found to fix this is:
Clean your project.
List item
Close the IDE.
With the Windows Explorer, navigate to your project.
Search for *.dcu Delete all the .dcu
Launch the IDE and load your project.
Compile it.
At this point, the code navigation (Ctrl+Click) should work.