Solved

Re: Problems migrating from v1 to v3

Posted on 1998-02-16
3
173 Views
Last Modified: 2010-04-04
Hi...
   I asked this question before and zitt responded with what I though would be a solution. It's only just now that I tried his suggestions and they didn't work. But I've already graded his answer and that question appears to be "closed"...I can't seem to get ahold of him again. So I'm repeting the question with his suggested answer. Hope you can help:

>(4) Error: "Incompatible types - 'String' and 'PChar'", caused
              >by this seemingly innocent piece of code:

              >deletefile(autoinput_file);

              >(autoinput_file is declared as a plain old String variable.
              >What's going on here?

              Question related to #5. See below.

              >Along that same theme, this line of code :

              >deletefile(homedir+'inpsort.txt')
              >('homedir' is a String variable)

              >..generates this error:

              >"Incompatible types: 'ShortString' and 'PChar'...Why? It was
              >fine in v1...

              OK... _ALL_ your string related code is because of one simple complier change.
              Delphi 3 (and 2?) use Windoze standard strings. I.E. Null terminated strings. Delphi
              calls these "long strings". To get rid of these problems, simply go into
              "Project/Options..." Menu. Select "Complier" tab. Then goto the "Syntax options"
              group box and de-select "Huge Strings" box. Your string problems should go away.
              You can also "isolate" segments of code with the {$H-} complier directive. No huge
              strings forces the complier into a more compatible mode.

              Hope this comments fix your problems!
              John

..Thanks for your attention to this. I hope you won't have to charge me more points since this was a question I already asked!

Cheers
  Shawn Halfpenny
  drumme59@sprint.ca
0
Comment
Question by:aztec
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1359368
Hi

If you declare a variable as a string, then you often need to type-cast it to a PChar.

E.g.
var
  s: string;
begin
  DeleteFile(PChar(s));
end;

Similarly, you can type-cast a PChar to a string:
(s is a string; p is a PChar.)
  s := string(p);

Is this what you are looking for?
JB

P.S.  I recommend leaving the Huge Strings option on.
0
 
LVL 5

Accepted Solution

by:
inter earned 50 total points
ID: 1359369
The problem is RESOLUTION. You want to call DeleteFile from SysUtils. However there are two other DeleteFile functions, one in Win32 and one in MAPI. So the following should solve

SysUtils.DeleteFile(homedir+'inpsort.txt');

Add sysutils to your uses clause and if you face this kind of weird error, search for multiple declerations of same function in different modules. So if you want to use win32 DeleteFile you should call Windows.DeleteFile . That is, think every DELPHI unit as a class holding several classes, variables, etc...

May this make all clear
Igor
0
 

Author Comment

by:aztec
ID: 1359370
Quite right Igor! Thank you!

Cheers
   Shawn Halfpenny
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month8 days, 5 hours left to enroll

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question