April 19, 2024, 08:46:47 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Creating and using DLL's

Started by J B Wood (Zumwalt), December 06, 2006, 12:41:13 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

J B Wood (Zumwalt)

I realize there is general information in the help file, so I figured I would take something that I put together in Aurora 101 as an EBasic DLL, along with giving explanation as to how it was put together. Hope you find this useful.

EBASIC1.EBA code

/* Create a new EBasic source file, call it EBASIC1.eba */

/*******************************************/
/*** The Export Keyword Tells The Linker ***/
/*** That The Specified Subroutines AreÂÃ,  ***/
/***ÂÃ,  ÂÃ, To Be Made Visible So To SpeakÂÃ,  ÂÃ,  ***/
/*******************************************/
/* these are our named function constructs */
export myFirstFunction
export myCalcFunction

/*************************************/
/*** Simple Hello World Subroutine ***/
/*************************************/
/* here we define the functions and what they do */
SUB myFirstFunction(),STRING
RETURN "Hello World!"
ENDSUB

/***************************************/
/*** Simple Math Addition Subroutine ***/
/***************************************/

SUB myCalcFunction(val1 as FLOAT, val2 as FLOAT),FLOAT
RETURN val1 + val2
ENDSUB

/* now compile this as a DLL, you will end upÂÃ,  */
/* with EBASIC1.DLL in your application folder */


EBASIC2.EBA Code

/* Create a new EBasic source file, call it EBASIC2.eba */

/* This shows how to use EBASIC1.dll */
/* Click on Tools then Create Import Library */
/* Choose the DLL we just created from the folder it was created in */
/* for instance, in my EBDev folder, I have a DLL folder under Projects */

/* first we connect to the LIB file, don't forget to do an create import library */
$use "EBASIC1.lib"

/* now we define which functions we would like to use in our application */
DECLARE IMPORT,myFirstFunction(),string
DECLARE IMPORT,myCalcFunction(val1 as float, val2 as float),float

/* now we use them */
int test
test=MessageBox(NULL,myFirstFunction(),"Hello World Call")
test=MessageBox(NULL,STR$(myCalcFunction(1,2)),"Calculate!")

/* rather simple isn't it? */

Shannara

Looking cool so far ... Any chance to show off making a dll in aurora and using it in EBasic?
Love is staying up all night with a sick child, or a healthy adult.

J B Wood (Zumwalt)

December 06, 2006, 02:14:15 PM #2 Last Edit: December 06, 2006, 02:28:00 PM by Jonathan (zumwalt) Wood
Taking the example that exists in the General section for Aurora's DLL's 101, you can create the DLL.
Using this example in the thread for creating an import library then using the $use "auroralibname.lib", you use it the exact same way as posted here for EBasic.

I can type up detailed information tonight.