Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Re: Problems migrating from v1 to v3

Posted on 1998-02-16
3
Medium Priority
?
177 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 200 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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

688 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