Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 452
  • Last Modified:

Problems migrating from Delphi 1 to Delphi 3

Hi...
  Having a HELL of a time migrating from v1 to v3. I installed v3 and re-compiled my app. There were several errors I hope you can help me straighten out (I called Borlands tech support - $2.95/min..ouch - they told me to check out some technical white paper on their site, I did - virtually incomprehensible!) :

(1) My app in v1 used a TabbedNoteBook with 10 pages that were split up into 5 TabsPerRow each. In v3, it appears that the TabsPerRow property doesn't work...it string out all 10 pages on one row one after another and it looks really ugly. Any suggestions or is this a bug in v3?

(2)I'm using the WinExecAndWait function:

Function WinExecAndWait(Path : string; Visibility : word) : word;
var
  InstanceID : THandle;
  PathLen : integer;
begin
  { inplace conversion of a String to a PChar }
  PathLen := Length(Path);
  Move(Path[1],Path[0],Pathlen);
  Path[PathLen] := #00;
  { Try to run the application }
  InstanceID := WinExec(@Path,Visibility);

(...and so on...)

   The line of code: Move(Path[1],Path[0],Pathlen);
was fine in v1, but in v3 it generates "Element 0 inaccessible - use "Length or "SetLength" compile error. How come?

(3) In that same "WinExecAndWait" function, specifically:

 Repeat
      Application.ProcessMessages;
    until Application.Terminated or (GetModuleUsage(InstanceID) = 0);

.. The "GetmoduleUsage" call generates this error: "Undeclared Identifier - 'GetModuleUsage'". How do I get around this?

(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?

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...

..Hope you can help me!

Cheers
  Shawn Halfpenny
  drumme59@sprint.ca
0
aztec
Asked:
aztec
  • 4
  • 4
  • 2
1 Solution
 
MatveyCommented:
I'll look at the tabbed notebook thing, but for now I sent you the component that executes applications in D3(I guess that it's what you need...

Enjoy the new version!
Matvey
0
 
aztecAuthor Commented:
Hello Bosis...
   Thanks for the ExecFile component...it works well! Have you had any luck investigating the TabbedNoteBook problem, as well as the 'Incompatible Types - String and Pchar' errors? Tell me Bosis, will an application run faster in the new Delphi v3 than in v1? I read somewhere that the .EXE file v3 produces is smaller, but will it run faster (ie. more efficient) than the same app compiled in v1? In other words if my app in v1 can perform its task in say 15 seconds, will that same app compiled in v3 perform the task faster than 15 seconds...or is there no difference?

Cheers
    Shawn Halfpenny
    drumme59@sprint.ca

P.S: Also, will the InstallShield Express that comes with Delphi v3 Professional work for applications created and compiled in Delphi v1? Or does it only work with apps compiled in v3?

0
 
MatveyCommented:
Is it a big problem transfering all the controls to the win95 version of that tabbed notebook?

And do you still need PChar? (I'm having problem to understand what for...)

Matvey
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
aztecAuthor Commented:
Hi Matvey...
  You wrote:

Is it a big problem transfering all the controls to the win95 version of that tabbed notebook?

..You mean the TPageControl thing? Yes, it would be a VERY big problem! I have 10 tabs and a LOT of components on each tab. I really don't want to have to do this.

And do you still need PChar? (I'm having problem to understand what for...)

.. I never said I needed PChar. i was just using regular String variables in my app in D1 and statements like 'deletefile(autoinput_file)' worked fine. It's only when I try to compile the same app in D3 do I get these errors - 'Incompatible types - String and PChar'. I'm not even USING PChar!
  D3 is starting to make me very angry!

Regards,
  Shawn
0
 
MatveyCommented:
Hmmmm, when I try to do this: deletefile('blabla') I don't get errors. And in help it's written that the parameter is a string parameter!
Maybe you should try to set some compiler options(just a guess)

And about the tabbed notebook -yes it looks like a bug. I think you can demand some answeres from Borland!

Sorry, nothing new for now. I'll try to change that component...
0
 
zittCommented:
Easy? Hardly.. too me days to figure these doosies out.

>Having a HELL of a time migrating from v1 to v3.

Welcome to my/our nightmare... And to make things worse the helpfiles suck so bad I wish someone would rewrite them. I'd pay for that.

>(1) My app in v1 used a TabbedNoteBook with 10 pages that were

Sorry, Can't speak to this problem.

>2)I'm using the WinExecAndWait function:

The line of code: Move(Path[1],Path[0],Pathlen);
was fine in v1, but in v3 it generates "Element 0 inaccessible - use "Length or "SetLength" compile error. How come?

Question related to #4,#5. See below.

>(3) In that same "WinExecAndWait" function, specifically:

>Repeat
> Application.ProcessMessages;
> until Application.Terminated or (GetModuleUsage(InstanceID) = 0);

>.. The "GetmoduleUsage" call generates this error: "Undeclared
>Identifier - 'GetModuleUsage'". How do I get around this?

Ah... See your Win32 helpfiles. GetModuleUsage is no longer supported in Win32 or Delphi 3. I did, however, figure out a workaround... My code is show below. It allows the same program to be complied in Delphi1 and D3.

{$IFDEF Win32}
FUNCTION GetModuleusage(ProgramHandle : HWnd) : Byte;
BEGIN
    GetModuleusage := Byte(IsWindow(ProgramHandle));
END;
{$ENDIF}

>(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
0
 
MatveyCommented:
Hmmm, like I thought - directives...
0
 
aztecAuthor Commented:
Hello John...
    Your suggestion below didn't work:

>(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

..STill getting those errors. Curiously enough though, it's only the 'deletefile' statement that is causing them!

Hope you can help!

Cheers
  Shawn
0
 
zittCommented:
The Huge string option should have fixed it. Try putting
{$H-} at the top of the offending unit. If that doesn't fix it, I don't have any other ideas... other than trying to convert the string to PChar to see if it works.
0
 
aztecAuthor Commented:
I just now tried Zitt's proposed answer for the "GetModuleUsage" problem I had. It didn't work. My app didn't wait for the called program to finish, it just kept on going.
  I'd like to change my grade for this question to "F". None of Zitt's proposed answers worked. I'll have to re-ask the questions and hope someone else answers them. Someone else (Igor) already took care of my "Incompatible types - Shortstring to Pchar" problem.

Shawn Halfpenny
drumme59@sprint.ca
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.

  • 4
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now