Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Passing strings as arguments to xll functions.
Yet another xll question. I'm trying to pass a filename as an argument to a
function defined in a c++ based xll file. The xll doesn't seem to be able to handle this. I've tried coding a conversion from byte-counted strings to null-terminated strings, but it didn't seem to help. If I run my conversion and then write the new string, which should be a null-terminated c string, to a file I get weird characters - like little rectangles. Anyways, I don't quite know how to fix this. I've included my function table and the function I'm trying to get to work. Any help is greatly appreciated. static char gszFunctionTable[NUM_FUNCTIONS][NUM_REGISTER_ARGS][MAX_LENGTH] = { {" ReadInData", // procedure " BJD", // type_text " ReadInData", // function_text " d1, filename", // argument_text " 1", // macro_type " Sample Add-In", // category " ", // shortcut_text " ", // help_topic " Re", // function_help " The first number to add.", // argument_help1 " The second number to add.", // argument_help2 }, {" GetNumberOfPoints", " JJD", " GetNumberOfPoints", " d1,filename", " 1", " Sample Add-In", " ", " ", " Gets number of points in data file", " The index of the header to retrieve", " ", } }; EXPORT int WINAPI GetNumberOfPoints(int d2,unsigned char* filename) { struct r32_data_header Old; int nw3[3]; // // load native format data file...should have .r32 suffix // FILE *in; int nw; unsigned char* pos = filename; int len = atoi( filename ); unsigned char* newstring = (unsigned char*)malloc( len * sizeof(char) + 1); // later, free this if( len 0 ) { while( isdigit( *pos ) ) // walk past the digits { pos++; } strcpy_s( newstring, pos, len ); // copy over the number of characters specified } newstring[len] = '\0'; // add null-terminator fopen_s( &in, "c:\\Jones\\excel stuff\\filetest.txt", "w" ); nw=fwrite(newstring,sizeof(filename),1,in); // nw=fread((char *)&Old,sizeof(struct r32_data_header),1,in); nw3[0] = Old.Nx; nw3[1] = Old.Ny; nw3[2] = Old.Nfreqs; return 0; fclose(in); } |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Passing Arguments in Excell | Excel Worksheet Functions | |||
Passing Arguments | Excel Programming | |||
Passing arguments to a sub routine... | Excel Programming | |||
passing strings | Excel Programming | |||
passing strings | Excel Programming |