Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing Arguments in Excell UB Excel Worksheet Functions 3 February 13th 07 04:08 PM
Passing Arguments Grant Reid Excel Programming 8 May 24th 04 01:39 PM
Passing arguments to a sub routine... Jeff Harbin[_2_] Excel Programming 2 January 29th 04 03:25 AM
passing strings pabs[_7_] Excel Programming 2 December 19th 03 06:25 PM
passing strings Sirron Excel Programming 2 August 27th 03 04:33 PM


All times are GMT +1. The time now is 08:38 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"