Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Component unit usage problem

Status
Not open for further replies.

cyberium

Programmer
Aug 25, 2001
8
NO
Anyone know how to fix this?

I'm writing a script engine component and I want it to use functions and procedures stored in an external unit called STXInternalTools. I have defined STXInternalTools in the script engine unit (STXScript) unit's uses clause, but functions residing in the STXInternalTools are only callable from the STXScript unit. I want to enable the script engine user/programmer to be able to access functions/procedures in the STXInternalTools unit through the STXScript unit (by simply writing STXScript1.CharToUpperCase(...) to take an example). I assume I have to redeclare each function from the STXInternalTools unit in the main component unit, and maybe add some kind of directive to each declaration to enable some kind of overriding, but how do I do that? I have tried several kinds of things and looked up as much help as possible from the Delphi manual, but I can't say I had much luck solving this problem.

It is important to enable access to STXInternalTools through STXScript in order to ease programming of custom script commands for the user of the component. Function and procedure identifiers must be the same for accessing from outside STXScript as inside STXScript. That is, a function called MyFunction() in STXInternalTools should be possible to call as MyFunction() not only from STXScript but also by calling STXScript1.MyFunction().

Here's a simplified pseudo-code of my STXInternalTools unit:
// STXInternalTools - start
unit STXInternalTools;

interface

uses SysUtils;

// --- Types ---
type TSTXCharset= set of #30..#255; //This contains ASCII characters 30 through 255 for use with dynamic sets.

// --- Service and Support Function Table ---
//Assembler optimized mathematical routines
function AsmInc(I: Integer): Integer;
function AsmDec(I: Integer): Integer;
function AsmAdd(I1,I2: Integer): Integer;
function AsmSub(I1,I2: Integer): Integer;
//String operation routines
function ReplaceCharFast(const S: string; Ch1,Ch2: char): string;
function CapitalizeStrChar(S: string; CharIndex: Integer): string;
function CharToLowerCase(Chr: Char): Char;
function CharToUpperCase(Chr: Char): Char;
//Language grammar routines
function STXVerifyLabel(S: string): Boolean;
function STXVerifyLabelDyn(S: string; AllowedChars: TSTXCharset): Boolean;
function SInd(S: string): LongInt;

implementation

function AsmInc(I: Integer): Integer;
asm
INC I
MOV @Result,I
end;
//And so on with more functions...

end.
// STXInternalTools - end

If I declare
function SInd(S: string): LongInt; override;
in the STXScript public section as well, I get a "Method 'SInd' not found in base class", so I guess using the override directive isn't the right way to achieve what I want...

-Steinar
 
Hi every1,

In case someone knows how to make a custom component add another unit to the component's parent form's uses clause, I'd be happy to know..

If it was possible, in the problem I wrote about in the above thread, to make STXScript add STXInternalTools to, say the Form1 uses clause, it would solve this issue... If the component user for some reason removed the uses clause addition of STXInternalTools it would be his or her problem of course.

Thanks

-Steinar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top