Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Functions

0 views
Skip to first unread message

Malgaras

unread,
Jul 29, 2000, 3:00:00 AM7/29/00
to
I'm trying to get this to work but it keeps saying Unsatisfied Forware or
externam declaration


unit varkey32;

interface

Uses SysUtils, Windows, Messages;

Function varkey(Stringthing : PChar) : Boolean;
implementation

var mainwin,kidwin:Thandle;
TargetPoint:Tpoint;
stringToSend:string;
Loopint:integer;
Stringthing: String;
begin
mainwin:=Findwindow('Notepad',nil);
if mainwin<>0 then
begin
targetPoint.x:=50; {make sure it is is the "writing" area of notepad}
targetPoint.y:=50;
end;
kidWin:=ChildWindowFromPoint(mainwin,targetpoint);
if kidwin<>0 then
begin
StringToSend:=Stringthing;
For loopint:=0 to length(stringToSend)-1 do
begin
PostMessage(Kidwin,wm_char,Ord(stringToSend[loopint]),0);
end;
end;
end.

Holger Koch

unread,
Jul 29, 2000, 3:00:00 AM7/29/00
to

Malgaras <malg...@iol.ie> wrote:
> I'm trying to get this to work but it keeps saying Unsatisfied
Forware or
> externam declaration
>
>
> unit varkey32;
>
> interface
>
> Uses SysUtils, Windows, Messages;
>
> Function varkey(Stringthing : PChar) : Boolean;
Ok, you export a unit, called varkey...
> implementation
>
but here, you did not implement the function!

> var mainwin,kidwin:Thandle;
> TargetPoint:Tpoint;
> stringToSend:string;
> Loopint:integer;
> Stringthing: String;
The code, you placed after the begin runs directly by starting your
application.
The code will be handled like initialistion-code (see initialisation
in Delphi-Help)

> begin
> mainwin:=Findwindow('Notepad',nil);
> if mainwin<>0 then
> begin
> targetPoint.x:=50; {make sure it is is the "writing" area of
notepad}
> targetPoint.y:=50;
> end;
> kidWin:=ChildWindowFromPoint(mainwin,targetpoint);
> if kidwin<>0 then
> begin
> StringToSend:=Stringthing;
> For loopint:=0 to length(stringToSend)-1 do
> begin
> PostMessage(Kidwin,wm_char,Ord(stringToSend[loopint]),0);
> end;
> end;
> end.
>
So you have to implement a function called varkey, returning Boolean
value or you delete
the "export" in interface-part of your unit.

For further information see delphi help with the topic "writing units"
or something sounds like this.

Greetings,

Holger

Dave Rudolf

unread,
Jul 29, 2000, 3:00:00 AM7/29/00
to
You need something like this:
------------------------------

unit varkey32;

interface

Uses SysUtils, Windows, Messages;

Function varkey(Stringthing : PChar) : Boolean;

implementation

Function varkey(Stringthing : PChar) : Boolean;
begin
.
.
.
end; {end of varkey function}

end. {end of unit}
---------------------------------------
You need the function header in both the interface and implementation
sections. This is because you may have more than one routine in a unit (in
fact, it seems like a waste to write a whole unit for only one routine). You
have to tell the complier which routine you are implementing For example:

---------------------------------------

unit Stuff;

interface

procedure DoStuff;
function TestStuff:BOOLEAN;


implementation

procedure DoStuff;
begin
{code for DoStuff}
end;

function TestStuff:BOOLEAN;
begin
{code for TestStuff}
end;

end.

---------------------------------------

Hope that clarifies things.


-------------------------------------------------------
http://members.home.net/dave.t.rudolf
http://members.home.net/stonemason


"Malgaras" <malg...@iol.ie> wrote in message
news:8lusbo$15...@bornews.borland.com...


> I'm trying to get this to work but it keeps saying Unsatisfied Forware or
> externam declaration
>
>
> unit varkey32;
>
> interface
>
> Uses SysUtils, Windows, Messages;
>
> Function varkey(Stringthing : PChar) : Boolean;

> implementation


>
> var mainwin,kidwin:Thandle;
> TargetPoint:Tpoint;
> stringToSend:string;
> Loopint:integer;
> Stringthing: String;

0 new messages