<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<TITLE>Message</TITLE>

<META content=2002-11-01 name=date>
<STYLE type=text/css></STYLE>

<META content="MSHTML 6.00.2900.2769" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=859364820-10112005><FONT face=Arial color=#0000ff size=2>I use 
several shared/library routines called from different places in programs.&nbsp; 
Sometimes in one of these I want to call a further routine which executes code 
that is relevant to the parent application only.&nbsp; What is the best way to 
do this in Delphi?</FONT></SPAN></DIV>
<DIV><SPAN class=859364820-10112005><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=859364820-10112005><FONT face=Arial color=#0000ff size=2>for 
example in other languages I could do:</FONT></SPAN></DIV>
<DIV><SPAN class=859364820-10112005><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=859364820-10112005><FONT face=Arial color=#0000ff 
size=2>example&nbsp; -1</FONT></SPAN></DIV>
<DIV><SPAN class=859364820-10112005><FONT face=Arial color=#0000ff 
size=2>Program1 calls Libraryroutine1</FONT></SPAN></DIV>
<DIV><SPAN class=859364820-10112005><FONT face=Arial color=#0000ff 
size=2>Libraryroutine1 calls routine with a fixed name eg 
UserRoutine1</FONT></SPAN></DIV>
<DIV><SPAN class=859364820-10112005><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=859364820-10112005><FONT face=Arial color=#0000ff size=2>And I 
would have several separate source versions of UserRoutine1, one for each 
application and the link file for the application would specify whihch one got 
linked in, and hence called and executed.</FONT></SPAN></DIV>
<DIV><SPAN class=859364820-10112005><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=859364820-10112005><FONT face=Arial color=#0000ff size=2>I 
can't do this in Delphi as the unit itself contains the linking information in 
the uses clauses.</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT>&nbsp;</DIV>
<DIV><SPAN class=859364820-10112005><FONT face=Arial color=#0000ff 
size=2>example - 2</FONT></SPAN></DIV>
<DIV><SPAN class=859364820-10112005><FONT face=Arial color=#0000ff size=2>In 
other languages I have see code like</FONT></SPAN></DIV>
<DIV><SPAN class=859364820-10112005><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=859364820-10112005><FONT face=Arial color=#0000ff 
size=2>Callroutine(routinename,arg1,arg2,arg3.....)&nbsp;&nbsp;where routinename 
is a string variable that can be set to the value you want in Application1, and 
the Callroutine would then call this routine Routinename with the arguments arg1 
arg2 etc&nbsp; (ie the routine name becomes a variable and can be pointed at 
different code.&nbsp; Is this possible or recommended in 
Delphi?</FONT></SPAN></DIV>
<DIV><SPAN class=859364820-10112005><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=859364820-10112005>example - 3</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=859364820-10112005></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=859364820-10112005>This 
is one way you can do it in Delphi - you have a shared routine UserRoutine1 
containing all the code for all applications that need 
it....</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=859364820-10112005></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=859364820-10112005>eg 
</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=859364820-10112005></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=859364820-10112005>procedure&nbsp;UserRoutine1...</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=859364820-10112005></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=859364820-10112005>if&nbsp; 
ExtractFileName(Application.exename)='Fred.exe' then</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=859364820-10112005>begin</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=859364820-10112005>&nbsp;&nbsp;&nbsp; ....</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=859364820-10112005>&nbsp;&nbsp;&nbsp; ....</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=859364820-10112005>end</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=859364820-10112005>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=859364820-10112005>if&nbsp; ExtractFileName(Application.exename)='Joe.exe' 
then</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=859364820-10112005>begin</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=859364820-10112005>&nbsp;&nbsp;&nbsp; ....</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=859364820-10112005>&nbsp;&nbsp;&nbsp; ....</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=859364820-10112005>end</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=859364820-10112005><SPAN 
class=859364820-10112005>&nbsp;
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=859364820-10112005>if&nbsp; 
ExtractFileName(Application.exename)='Bill.exe' then</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=859364820-10112005>begin</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=859364820-10112005>&nbsp;&nbsp;&nbsp; ....</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=859364820-10112005>&nbsp;&nbsp;&nbsp; ....</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=859364820-10112005>end</SPAN></FONT></DIV></SPAN></SPAN></FONT></DIV></SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=859364820-10112005></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=859364820-10112005>This 
works but is very clumsy in that code not relevant to the application is 
compiled in, and also objects/forms/globals relevant to one application are not 
useable as other applications will not be using them.&nbsp; In some cases where 
the UserRoutine is doing very limited local stuff this may be fine, or limited 
numbers of these can be passed in as parameters through LibraryRoutine1 to 
UserRoutine1.</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=859364820-10112005></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=859364820-10112005>What 
is the recommended or most elegant&nbsp;way to do this in Delphi?&nbsp; I am 
thinking maybe&nbsp;the easiest is&nbsp;using an include&nbsp;directive to pick 
up the relevant library code for LibraryRoutine1&nbsp;routine directly into the 
application unit - which already contains code for 
UserRoutine1</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=859364820-10112005></SPAN></FONT>&nbsp;</DIV>
<DIV class=Section1>
<P class=MsoAutoSig align=left>John<FONT face=arial color=navy 
size=1></P></DIV></FONT></BODY></HTML>