LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

MultiFileSelectPopup

The prototype MultiFileSelectPopup (char defaultDirectory[], char defaultFileSpec[], char fileTypeList[] char title[], int restrictDirectory, int restrictExtension, int allowCancel, int numberOfSelectedFiles, char **fileList) requires int numberOfSelectedFiles and char** for filelist according to the manual. But when compiling it always asks for pointer to int and pointer to pointer to pointer to char instead. Is it a bug?
0 Kudos
Message 1 of 9
(3,175 Views)
Actually, the function prototype (in userint.h) shows them as int* and char***. Maybe you are referring to the function panel help which shows them as int(passed by reference) and char**(passed by reference). Since they say "passed by reference" that adds a level of indirection since these are output variables. You code should pass in an int and an char** by reference since this function will fill those variables. Like this:

int numFiles;
char** fileNameList;

MultiFileSelectPopup ("", "*.*", "", "", 0, 0, 1, &numFiles, &fileNameList);

Best Regards,

Chris Matthews
National Instruments
0 Kudos
Message 2 of 9
(3,175 Views)
Thanks, Chris,

I was confused by the CVI on-line help. I cannot find any word about passed by reference in it. Maybe it should be updated.

Dennis Zhou
0 Kudos
Message 3 of 9
(3,175 Views)
I understand. Passing by reference and pointers are general C programming topics (not related to CVI specifically). We don't have general C programming instruction in our help. If you are looking for a good book, you may want to pick up The C Programming Language by Kernigham and Ritchie.

Best Regards,

Chris Matthews
National Instruments
0 Kudos
Message 4 of 9
(3,175 Views)
"Chris Matthews" wrote in message
news:506500000005000000F3990000-1027480788000@exchange.ni.com...

> If you are looking for
> a good book, you may want to pick up The C Programming Language by
> Kernigham and Ritchie.

Which used to be supplied as part of the box set of manuals now sadly absent
and much missed from your present distribution.
0 Kudos
Message 5 of 9
(3,175 Views)
I understand that. What I meant is that the prototyp in the help should be
MultiFileSelectPopup (char defaultDirectory[], char defaultFileSpec[], char fileTypeList[] char title[], int restrictDirectory, int restrictExtension, int allowCancel, int *numberOfSelectedFiles, char ***fileList), or
MultiFileSelectPopup (char defaultDirectory[], char defaultFileSpec[], char fileTypeList[] char title[], int restrictDirectory, int restrictExtension, int allowCancel, int numberOfSelectedFiles[], char **fileList[]), instead of
MultiFileSelectPopup (char defaultDirectory[], char defaultFileSpec[], char fileTypeList[] char title[], int restrictDirectory, int restrictExtension, int allowCancel, int numberOfSelectedFiles, char **fileList).

Thanks,

Denn
is Zhou
0 Kudos
Message 6 of 9
(3,175 Views)
Your right, I was looking at the function panel help, not the online reference. It's incorrect in the online reference help.

Chris
0 Kudos
Message 7 of 9
(3,175 Views)
Actually, the book that used to be supplied with CVI wasn't K&R but rather "C A Reference Manual" by Harbison & Steele, ISBN 0-13-326224-3. This is by far the best C book I've ever encountered. I wouldn't want to learn C from it, but if you already generally know the language it's a real gem of a reference. Who knows a language the best? Compiler writers. And Harbison & Steele are compiler writers (Tartan, Inc.).

As far as pointers, I always say "pointers are evil". Having to add an extra level of indirection on a value that's already referenced twice is confusing to say the least. Any wonder that newer languages (Java, C#) don't use pointers?

One way to help understand parameters in C (as opposed to other langua
ges) is to consider that in C, all parameters are pass-by-value, but sometimes the value being passed is a pointer 😉 Plus, you have to do the grunt work of creating references and doing dereferencing for yourself. Ada for example, doesn't require a compiler to implement pass by value or pass by reference - it's up to the compiler how to do it, and the user is blissfully unaware of the exact mechanism.

Also remember "the golden rule of parametrization". A passed parameter is indistiguishable from a temporary (in C, "automatic") variable initialized to the value (actual value or pointer value) passed by the calling routine.

The CVI debugger "Variables" window helps you figure out what's happening by dereferencing pointers to variables for you.

Hopefully I haven't increased the confusion 😉
0 Kudos
Message 8 of 9
(3,175 Views)
I agree, but cann't complain about the three-times references, as long as the prototype tells users what it is. I have all the good books.
0 Kudos
Message 9 of 9
(3,175 Views)