Solved

Problems migrating from Delphi 1 to Delphi 3

Posted on 1998-01-16
10
404 Views
Last Modified: 2010-04-04
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
Comment
Question by:aztec
  • 4
  • 4
  • 2
10 Comments
 
LVL 3

Expert Comment

by:Matvey
ID: 1356908
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
 

Author Comment

by:aztec
ID: 1356909
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
 
LVL 3

Expert Comment

by:Matvey
ID: 1356910
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
 

Author Comment

by:aztec
ID: 1356911
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
 
LVL 3

Expert Comment

by:Matvey
ID: 1356912
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Accepted Solution

by:
zitt earned 50 total points
ID: 1356913
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
 
LVL 3

Expert Comment

by:Matvey
ID: 1356914
Hmmm, like I thought - directives...
0
 

Author Comment

by:aztec
ID: 1356915
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
 

Expert Comment

by:zitt
ID: 1356916
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
 

Author Comment

by:aztec
ID: 1356917
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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 my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now