cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

DLL arguments

DLL arguments

Hi,

I would to extend MathCad by creating a DLL which will interface with netCDF/HDF files. The Mathcad document on creating DLLs seems to indicate that only COMPLEXSCALAR and COMPLEXARRAY types can be passed whereas for my proposed DLL I would have to pass strings (eg the filename to open).

Is it possible to pass strings as arguments to such DLL functions?

Phil.

P.S. Has MathCad already been extended so it can interface to netCDF/HDF files? If so is it freely available and where can I obtain it?
4 REPLIES 4

DLL arguments

There are a few undocumented variable types that you can pass to a user DLL, including a string type. I don't have a reference here - you may want to look in older discussions.

The technique I use is more brute-force but is also documented:
1) In the Mathcad worksheet create an ASCII array containing the string elements using str2vec()
2) Pass this array to the DLL function, which may look like this:

#define FILENAME_TOO_LONG 6
#define CANNOT_ACCESS_FILE 7


LRESULT fProcessFile( COMPLEXARRAY * const COutput, const COMPLEXARRAY * const CFilename )
{
char fname[2000];
long i;
HANDLE hFile;

// Create file name
if( CFilename->rows > 1998 ) return MAKELRESULT( FILENAME_TOO_LONG, 1);

for( i = 0; i < CFilename->rows; i++ ) fname[i] = (char) CFilename->hReal[0][i];
fname[i] = '\0';

// Try to open the file
hFile = CreateFile( fname, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL );
if( hFile == INVALID_HANDLE_VALUE ) return MAKELRESULT( CANNOT_ACCESS_FILE, 1);

...

CloseHandle( hFile );
return 0;
}

Xavier

Re: DLL arguments

After some years... does anyone have this dll?

I really don't want to spent time for creating my own.

I would appreciate any help.

Thank you in advance.

Re: DLL arguments

If you really need this and you will start to implement it, I'll try to help you.

Re: DLL arguments

A custom DLL has been created that supports the HDF5 format (READ/WRITE).

It has been created for Prime 3.0.

http://communities.ptc.com/docs/DOC-4293

Announcements