Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Creating Function with Optional Parameters


5 replies to this topic

Taco Bell

Taco Bell

    IS6 Expert

  • Moderators
  • 1,281 posts

Posted 12 September 2002 - 20:50

I'd like to make a function like SprintfBox which has optional parameters.  How might I go about doing this?

By the way, the help states the SprintfBox definition as being the following:
SprintfBox (nType, szTitle, szFormat [,arg] [,...]);
user posted image

EberhardH

EberhardH
  • Members
  • 137 posts

Posted 13 September 2002 - 08:08

How about using an array as argument?

First prepare an array, resize it, fill it. Then hand it over to the function. The function gets its size with SizeOf() and can retrieve the elements.

Eberhard

Taco Bell

Taco Bell

    IS6 Expert

  • Moderators
  • 1,281 posts

Posted 13 September 2002 - 15:22

Yeah, I could use an array, but that requires the parameters to all be of the same type.

I found a different workaround and actually don't have to figure this out anymore, but it would be nice to know still for future reference.
user posted image

prozacrefugee

prozacrefugee
  • Members
  • 38 posts

Posted 14 September 2002 - 00:32

Overloaded functions like SprintFBox are common in C++, but I think InstallShield identifies user functions only by their name, not the parameters (no name mangling), so you can't overload them.  
You might be able to do this by coding your function in a DLL, but install shield might still reject the header file.

Taco Bell

Taco Bell

    IS6 Expert

  • Moderators
  • 1,281 posts

Posted 14 September 2002 - 01:45

Yeah, I think you're right prozacrefugee.  I tried making functions with the same name before, but a differing number of parameters and the compiler barked at me each & every time.  Oh well. :(

Out of curiousity, does anyone know if MSI allows/supports this?  Especially since someday, I'm expecting to be forced to move over to it. :angry:
user posted image

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 15 September 2002 - 18:45

MSI doesn't support custom functions, but custom scripts. These can be written in VBScript, JScript, DLL or EXE (or with InstallShield in InstallScript). Not sure if VBScript or JScript support this.