Solved

Re: Problems migrating from v1 to v3

Posted on 1998-02-16
3
172 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

734 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