digitalFAQ.com Forums [Archives]

digitalFAQ.com Forums [Archives] (http://www.digitalfaq.com/archives/)
-   Avisynth Scripting (http://www.digitalfaq.com/archives/avisynth/)
-   -   DLL - A Delphi Ex with vmath.dll (small steps) (http://www.digitalfaq.com/archives/avisynth/2543-dll-delphi-vmathdll.html)

vhelp 02-08-2003 11:09 PM

DLL - A Delphi Ex with vmath.dll (small steps)
 
I thought of opening up the Delphi area w/ a discussion on DLL
coding, since I (and others) have a dream of writing their own
DLL functions for AVIsynth and other apps that accepts DLL's.
As you all know, currently, there exist NO method of feeding
a Delphi create DLL into AVIsynth to date, though there are
some that are forging ahead (myself included) in an attempt to
end that void.

Below, is a demonstration (a small step) in an effort to try
and share what little knowledge I have in DLL development.
This is basically an excercise of porting a DLL into other
Programming enviornments. An attempt to see weather or not other
languages can access the DLL's function. I hope you Delphi,
Visual Basic and C/C++ peoples can use the two Functions
in your testing stages. This DLL works w/out any trouble under
Delphi 6.

Example:
Min(1,5) = 1
Max(7,2) = 7

Note:
be sure to install the vmath.dll file somewhere in an easy to
get to place, like your D:\ drive. In my code (see below) I
used my D:\ directory for easy (less typing) managing, since
I'm always working on them, it was worth the trouble of porting
into the Library area of Delphi. And, if the real world (myself
anyways) I'm always defaulting my files ie, *.DLL to my closest
director for quick access.


.. code sample for Delphi, ..VB and C/C++ can follow w/ their own
syntax ..

Code:

implementation

{$R *.dfm}

function Min(x,y: integer): integer; external 'd:\vmath.dll';
function Max(x,y: integer): integer; external 'd:\vmath.dll';
 .
 .
procedure TForm1.Button1Click(Sender: TObject);
begin
 .
 . // use your Min(x,y) and Max(x,y) functions can go here..
 . // substitue the x,y w/ values or use an edit control as in
 . // my demo app above.
 .

Download: vmath.dll

Using these math functions shouldn't be too difficult to set up in
your platform ( Delphi/VB/C/C++ ) The outcome is to have the two
Functions Min() and Max() choose their required ranged values ie,
Min() will search for the Lowest value in it's x,y and record it.
Max() will search for the Highest value in it's x,y and record it.
That's about it for their purposes, but the real purpose of this
excercise is to see if your able to import the DLL into your language.
Remember, small steps.

Well, check it out. Fool around a little w/ how parameter passing
is done. For those C/C++ coders, (w/out testing) I think that this
DLL should work if you are observant about the param passing law w/
Pascal - some domb sh_t like that.

If you have any problems geting them to work, I will try and make
whatever effort I can to get you up and working w/ this DLL. So,
if you'd like to participate, feel free to do so.

I have some other ideas and excercises, but this is enough for now.
Thanks for your participation.. oh, and feel free to join in on any
ideas you may have of your own too. ok, and have a good evening all.
-vhelp

vhelp 02-09-2003 12:28 AM

Sorry peoples, forum seems to be having problems w/ images all the sudden. Also, forgot to upload the DLL sample for you's to try, so again:

Download: vmath.dll

Download: 37.(dll).sample.05.exe

As I was saying, try you hand at the vmath.dll under your
compiler. Have fun.
-vhelp

vhelp 02-10-2003 12:54 AM

Hello everyone.

Below, is an included VBA version (Visual Basic should work too)
I didn't realize that my previous vmath.dll would not work w/ VBA
or VB for that matter. Sorry for the grief. To make up for this,
I have included the source code for VBA (MS Access version)
I do not have Visual Basic, though I do have VB version 3, it's
actually 16bit version. I didn't think it worth it, being that we
are all 32bit ready. And, based on my understanding, Office 97's
VBA is 32bit ready. So, I went with this approach, and it's not
such a bad idea after all. I can now test VB against my Delphi
apps.

Ok, so here is the code snipplet as well as the VBA app for MS Access.
Play around with it to get an understanding of how it works.
Remember, these functions are not included w/ VBA, hence my "v" behind
the funcitons ie, vMin etc.

Enter this in your Form1's Class:
---------------------------------

Code:

Option Compare Database
Option Explicit

Dim x As TextBox

Private Sub Min_Click()
  Min.Caption = "Min ( " & vMin(Text1, Text2) & " )"
  Text3 = Min.Caption
End Sub

Private Sub Max_Click()
  Max.Caption = "Max ( " & vMax(Text1, Text2) & " )"
  Text3 = Max.Caption
End Sub


Remember to substitute the drive/directory locatoins ie, "d:\vmath.dll"
with where ever you put the vmath.dll at.

Then, enter this in your Module:
--------------------------------
Code:

Option Compare Database
Option Explicit

Public Declare Function vMin Lib "d:\vmath.dll" (ByVal x As _
 Integer, ByVal y As Integer) As Integer
Public Declare Function vMax Lib "d:\vmath.dll" (ByVal x As _
 Integer, ByVal y As Integer) As Integer

http://www.digitalfaq.com/archives/error.gif

An Office 97 (MS Access) version w/ modified vmath.dll:
Download: vmin-vmax.rar

Notes:
* don't mix the vmath.dll w/ the previous one I posted. The
previous one will work w/ Delphi as is. It's only the newer one I
just posted on this thread, which is the one modified to work with
VB/VBA.
* The MS Access version (since I chose not to install VB 3.0) just
demonstrates the usage in this enviornment. I'm gonna assume that
VB users will be able to use code above w/ modified DLL (above) w/ out
any issues. So, even if you don't have Delphi, but most probably
Office 97 or higher, you should be able to try out this Excercise
anyways (if not, for curiousity purposes)
* I could have changed the newer DLL version name, but that would of
ment for me to change all the source codes, and the VBA as well. So,
at best, I thought to *.RAR the file, and then you could just copy
THAT DLL file to ANOTHER location on your hard drive (so not to
confuse yourself or the app)

Remember, all this, in reference to trying to find/devise a way to
develop DLL's for use w/ AVIsynth (even vdub, if possible) and other
apps too, but more important, AVIsynth. I've learned, that nothing
is impossible, as long as you believe so, else, in some experiences,
..the opposite. But, I'm hoping to spir up sparks in some of yous,
that have programming (hacking) experience. It doesn't have to be
perfect either. ..can be a wrapper DLL or something. Ok, enough said.

VB: Visual Basic
VBA: Office 97's MS Access

That should be it, for you VB/VBA users
-vhelp


All times are GMT -5. The time now is 10:14 AM  —  vBulletin © Jelsoft Enterprises Ltd

Site design, images and content © 2002-2024 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2024 Jelsoft Enterprises Ltd.