12.07.2015 Views

Calling 32-bit NAG C DLL functions from Visual Basic

Calling 32-bit NAG C DLL functions from Visual Basic

Calling 32-bit NAG C DLL functions from Visual Basic

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

4stopit = 0rk = 3rk = 1where FALSE = 0 and TRUE = 1. The above example illustrates that, by default, enumeratorsin a givenCenumeration type declaration start at zero and increase by 1 as thedeclaration is read <strong>from</strong> left to right. However, if a given enumerator is assigned a valuethen subsequent enumerators continue the progression <strong>from</strong> the assigned value.StructuresMany of the <strong>DLL</strong> routines use structures in their argument lists. Sometimes, for examplein the d02 and e04 chapters, these structures are rather complicated and may contain otherstructures. When the structure is relatively simple it is often convenient to dene a <strong>Visual</strong><strong>Basic</strong> user-dened type and then make a direct call to the <strong>DLL</strong> routine. Complicatedstructures are most easily dealt with by the use of an auxiliary <strong>DLL</strong> (this is illustrated inthe Optimize example in Appendix C).A structure that is required by nearly all of the routines is the type NagError. This isdened as:typedef struct fint codeBoolean printchar message[512]void (*handler)(char*, int*,char*)Integer errnumg NagErrorThe corresponding <strong>Visual</strong> <strong>Basic</strong> user-dened type is:Type NagErrorTypecode As Longprintm As LongMessage(511) As String * 1handler As Longerrnum As LongEnd Typewhere both int, Integer and Boolean types have been replaced by Long and the pointerto the handler function has been replaced by a structure memberoftype Long.As another example the type Nag Spline (used by routines e02bac and e02bbc) is denedas:typedef struct fInteger ndouble *lamdadouble *cInteger init1Integer init2g Nag Spline

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!