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

x
?
Solved

How to call a function in library code

Posted on 2004-10-14
11
Medium Priority
?
166 Views
Last Modified: 2010-04-05
Dear advisor

The code

library aaaaa ;

Function Total(X, Y: Integer): Integer; stdcall;
begin
   x := ChoiceQuanTiTy(x,y) ;
   Total := x + y ;
end;

Function ChoiceQuanTiTy(X, Y: Integer): Integer; stdcall;
begin
   if X < Y then ChoiceQuanTiTy := X else ChoiceQuanTiTy := Y;
end;

exports
  Total,
  ChoiceQuanTiTy ;
begin
end.

[Error] Project2.dpr(5): Undeclared identifier: 'ChoiceQuanTiTy'

Please correct for me. How to use a function in the same library
0
Comment
Question by:namcit99
[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
  • 5
  • 3
  • 2
  • +1
11 Comments
 
LVL 17

Expert Comment

by:geobul
ID: 12305970
library aaaaa ;

Function ChoiceQuanTiTy(X, Y: Integer): Integer; stdcall;
begin
   if X < Y then ChoiceQuanTiTy := X else ChoiceQuanTiTy := Y;
end;

Function Total(X, Y: Integer): Integer; stdcall;
begin
   x := ChoiceQuanTiTy(x,y) ;
   Total := x + y ;
end;

exports
  Total,
  ChoiceQuanTiTy ;
begin
end.

Regards, Geo
0
 

Author Comment

by:namcit99
ID: 12306029

Any other ways , if we do not consider on position ?
0
 

Author Comment

by:namcit99
ID: 12306048

IF do that, i already know .

Please show me the command to shutdow window. that command for shutdown depends on version of window ?

Or the command to close the active application on window.

Because i want comething to appear when they use my program but not register
0
Independent Software Vendors: 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!

 
LVL 17

Accepted Solution

by:
geobul earned 80 total points
ID: 12306212
library aaaaa ;

Function ChoiceQuanTiTy(X, Y: Integer): Integer; stdcall; forward;

Function Total(X, Y: Integer): Integer; stdcall;
begin
   x := ChoiceQuanTiTy(x,y) ;
   Total := x + y ;
end;

Function ChoiceQuanTiTy(X, Y: Integer): Integer; stdcall;
begin
   if X < Y then ChoiceQuanTiTy := X else ChoiceQuanTiTy := Y;
end;

exports
  Total,
  ChoiceQuanTiTy ;
begin
end.

You should 'consider on position'

Regards, Geo
0
 
LVL 4

Expert Comment

by:Colin_Dawson
ID: 12313513
Position is everything.   Another way, which gets more compliated still....


library aaaaa ;

uses
  Unit1;  //I can't be bothered to think of anything better.

begin
end;




unit Unit1;

interface

Function Total(X, Y: Integer): Integer; stdcall;
Function ChoiceQuanTiTy(X, Y: Integer): Integer; stdcall;

exports
  Total,
  ChoiceQuanTiTy;

implementation

Function Total(X, Y: Integer): Integer;
begin
   x := ChoiceQuanTiTy(x,y) ;
   Total := x + y ;
end;

Function ChoiceQuanTiTy(X, Y: Integer): Integer;
begin
   if X < Y then ChoiceQuanTiTy := X else ChoiceQuanTiTy := Y;
end;

end.


I can't think of any more variations on this theme.  geobul has already covered the others.
0
 

Author Comment

by:namcit99
ID: 12314858

both of answer are good. So how to send the point to both
0
 

Author Comment

by:namcit99
ID: 12315011

I can not see "Split Point"
0
 
LVL 17

Expert Comment

by:geobul
ID: 12316827
Increase question points to 40 and split them. The minimum amount of points which can be assigned to an expert is 20.
0
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 12319017
Guys... Please use the Result varuable...


library aaaaa ;

Function ChoiceQuanTiTy(X, Y: Integer): Integer; stdcall; forward;

Function Total(X, Y: Integer): Integer; stdcall;
begin
   x := ChoiceQuanTiTy(x,y) ;
   RESULT := x + y ;
end;

Function ChoiceQuanTiTy(X, Y: Integer): Integer; stdcall;
begin
   if X < Y then RESULT := X else RESULT := Y;
end;

exports Total, ChoiceQuanTiTy ;
begin
end.

Borland is different here from the Pascal standard simply because it's a bit more readable. If you use ChoiceQuanTiTy instead of Result, a reader might actually think you're calling the routine again, recursively...

To split points, you need to increase the points for this Q to 40 and split it. The minimum points any expert can get is 20 points. (But my remark is for free!)
0
 
LVL 4

Expert Comment

by:Colin_Dawson
ID: 12324257
my remark was for free too.   I decided not to point out the Result issue, so as not to confuse things.
0
 

Author Comment

by:namcit99
ID: 12335316
thank for all consider

-)
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

721 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