[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CL_My experience with a DLL



PureBytes Links

Trading Reference Links

As a matter of programming convention I use the return value of the DLL to
return an error code.  I never return the value to EL with the return value. 
What I do is pass a EL variable by reference to the DLL as one if its
parameters.  When you declare the DLL in EL make sure  that this variable is
declared as lpfloat.  When you use the function in EL it should look like
&Value1 as an argument.  The &   passes the ref but you probably knew that.

Seeing the code would help.

Chuck Kaucher

At 09:38 AM 9/23/99 -0400, Barry Kaufman wrote:
>
>I finally took the time to master the PowerBasic 16 bit DLL compiler and
>I generated a test DLL for TS 4.0.  I coded the Tillson T3 moving
>average in the DLL and compared it with T3 written in EL.  Calculation
>time for 30 years of daily SP500 close was 3.5 seconds for EL vs. 0.7
>seconds for the DLL.  Improvement should be even more after subtracting
>TS's overhead to load the price data.  The chart of both methods
>overlayed perfectly to confirm the DLL implementation.  I used double
>precision float variables in the DLL for intermediate results because
>that is what I will use for future, more complex and accuracy critical
>applications.  DLL file size was only 4.6K and far less than that will
>subtract from TS's 64K program limit.
>
>But, there was a problem that I had to work around and would like to
>resolve.  I had no problem passing floats from TS to the DLL, but could
>not pass a float from the DLL function back to TS.  I could however pass
>an INT or a LONG to TS.  I settled on a LONG which gave more than
>adequate resolution because in the DLL I multiply the final float result
>by 1000 before converting to LONG, and then after TS converts this back
>to float, I divide by 1000.  The factor could have just as well been
>10000 because of the high dynamic range of a 32 bit signed integer.
>This has no bearing on numerical accuracy where it counts - in the DLL,
>where filters, FFT's, etc. will be done.  It only involves the last
>transfer to TS where only conditional testing for buy - sell, plotting,
>etc. will be done.
>
>BUT, I still want to use either the FLOAT or LPFLOAT transfer to TS in
>DefineDLLFunc: or understand why they don't work.  So, here are
>questions:
>
>1)   I assume I can use FLOAT or LPFLOAT without needing to activate
>TS_KIT.DLL.  Is this correct?
>
>2)   I programmed my DLL function to output a 32 bit pointer for the
>address where its floating point result was.  LPFLOAT didn't work.  In
>fact, LPLONG and LPINT didn't work either when I programmed my function
>to output a 32 bit pointer for address of a LONG and then an INT result
>respectively.  So, what is TS's LPxxx looking for?
>
>3)   PBDLL will output C convention, Pascal convention and also some
>other ways specific to VisualBasic.  It can also output a float for the
>floating point processor stack.  I tried all of these to no avail.
>
>I know that many of you are wizards at C++ version 1.52.  I am a very
>proficient BASIC programmer, write utilities, test programs, and do a
>lot of embedded DSP and control processor assembly as well, but I never
>got around to mastering C.  So I ask that you please explain in terms of
>memory, register and stack mapping rather than in C terminology.  I have
>read a dozen documents (from Omega, Hashnums, Global-Pro, etc.) on
>interfacing DLL's to TS, plus everything about DLL's on the "Omega List"
>for the last two years, but still can't figure the parameter passing
>rules for TS's DefineDLLFunc:.  Everything is explained as "how to use"
>C++ version 1.5x.
>
>Lastly, the PowerBasic 16 bit compiler is proving to be an excellent
>accessory to TS4.  It is damn fast, generates lean code, and has all the
>amenities of a structured high level language:  Functions, subroutines,
>huge multi-dimensional arrays, global and local variables, array
>sorting, etc.  And, program and data size is unlimited.  I will be
>moving math stuff and some conditional testing into DLL's from now on.
>
>- Subscription Information link -
>http://www.markbrown.com/list.htm
>