Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DLL Talk / Delphi - Making a command with no return.... Help Please

Author
Message
The Lone Programmer
21
Years of Service
User Offline
Joined: 29th Jan 2003
Location: California, USA
Posted: 25th Jun 2005 00:55
Hey,

I have been very successful in making DBP commands with a return, whether it be string or integer.

Well I don't always want there to be a return. How do I make a TPC DLL in Delphi that doesn't require a return?

I want to go into DBP and type something like:
Print "hello"

I dont want a command like:
Result = Print "hello"

So how would I do it? Would I throw a Null into there or something? What would be my steps for making a simple command that doesn't return any values?


Thanks,
The Lone Programmer

Mess With The Best, Die Like The Rest.
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 25th Jun 2005 02:34
In Delphi use a "procedure" instead of a "function"; in the resource file delete the bracket "[".


Play Nice! Play Basic! Version 1.073
The Lone Programmer
21
Years of Service
User Offline
Joined: 29th Jan 2003
Location: California, USA
Posted: 25th Jun 2005 02:50
How can that be it?

I tried and still wont work.









Tell me which part of those is wrong please. I don't know how to make a string table when I'm not returning anything.

When I run in DBP it doesn't beep or wait. Just exits out with no error. Beep is just suppose to make a system beep.

Also why do I not have the same kind of freedom in making Procedures like I did functions?

I wanted to do:


It wouldn't work. I got an error in Delphi.

Any way if you could give me a little working example of a Dll that returns nothing and works I would greatly appreciate it.

Why no more AIM empty?


Thanks,
The Lone Programmer

Mess With The Best, Die Like The Rest.
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 25th Jun 2005 03:04 Edited at: 25th Jun 2005 03:05
The resource string is correct. Your problem seems to be that you haven't included sysutils (that's where the Delphi procedure "Beep" is defined).
So what happens when you have
?
This procedure will call itself until the doc comes.

While this

will of course produce an error message, 'cause Beep isn't defined anywhere.

So just put SysUtils in the uses clause, or- if you don't want to bloat the DLL- use the Windows API function MessageBeep(MB_OK) instead of Beep, which will produce the same sound.


Quote: "Why no more AIM empty?"

Only when necessary, as I found it rather distractive.


Play Nice! Play Basic! Version 1.073
The Lone Programmer
21
Years of Service
User Offline
Joined: 29th Jan 2003
Location: California, USA
Posted: 25th Jun 2005 03:39
I included SysUtils to the uses section of my code. I would receive an error if I didn't do that.

Why would it still not work then? Here is my whole code:



Now I am guessing I have nothing wrong there. But I'm an Uber Newb so you never know.


Am I not able to define my own procedures? Must they already exist in the Delphi context? Functions I can do whatever the hell I want to them, but I don't know the laws of procedures.

Please respond back.

Thanks,
The Lone Programmer

Mess With The Best, Die Like The Rest.
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 25th Jun 2005 03:51
Procedure Beep; cdecl;
Begin
Beep; // This causes to the procedure to call itself
End;

This procedure calls itself. You need to rename it.
The only difference between function and procedures is that the latter doesn't return anything otherwise they behave the same.


Play Nice! Play Basic! Version 1.073
The Lone Programmer
21
Years of Service
User Offline
Joined: 29th Jan 2003
Location: California, USA
Posted: 25th Jun 2005 04:02
Hmm I am confused still.

If I rename my procedure I get an error message on the command
Beep;

Do I have to define it in a variable or something?

Var Beepyness: Beep;

???

Im confused.

The Lone Programmer

Mess With The Best, Die Like The Rest.
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 25th Jun 2005 04:05
What error message?


Play Nice! Play Basic! Version 1.073
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 25th Jun 2005 04:09
Nevermind, I just noticed the order in the uses clause. I'll explain it in a minute.


Play Nice! Play Basic! Version 1.073
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 25th Jun 2005 04:19 Edited at: 25th Jun 2005 04:20
Your problems are caused by the following:

We have two procedures/functions called "Beep" that come with Delphi. One is defined in SysUtils (it's a procedure that has been there since Turbo Pascal) and one is defined in Windows (as there's a WinAPI function of the same name).
Since there's no real namespacing in Delphi prior to version 2005 (don't know about version 8), Delphi uses the "closest" one in the project, ie. the one that is last in the uses clause.
Example when you have this:

It'll use the Beep from SysUtils, while this

will use the Beep from Windows. As you can see the Windows' Beep needs two parameters and that's why you get an error message.

Solution
Either change the order in you uses clause or tell Delphi explicitly which Beep to use. Example:



Play Nice! Play Basic! Version 1.073
The Lone Programmer
21
Years of Service
User Offline
Joined: 29th Jan 2003
Location: California, USA
Posted: 25th Jun 2005 04:30
Empty did I ever tell you how much of a genious you were? Well you are a super genious.

I examined your GUI example you gave a while back and I tried to learn from it.

The one with the buttons and edit boxes and junk. I could only screw with the stuff on the panel. I couldn't make a button for example glued to the black screen of DBP. Maybe it is incredibly hard and too far beyond me. I don't know.

Did you design the GlobStruct file or did someone else build it. If so who did? Or is it an actual file in delphi?


Thanks again for the help man,
The Lone Programmer

Mess With The Best, Die Like The Rest.
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 25th Jun 2005 07:53
Quote: "I examined your GUI example you gave a while back and I tried to learn from it."

Actually I don't remember that one.


Quote: "Did you design the GlobStruct file or did someone else build it. If so who did? Or is it an actual file in delphi?"

I wrote it. Although it's from version 5.4 or something. Haven't translated the latest version (5.8) yet- I just don't have time for that at the moment.


Play Nice! Play Basic! Version 1.073

Login to post a reply

Server time is: 2024-04-18 14:36:15
Your offset time is: 2024-04-18 14:36:15