Quinch Posted February 2, 2012 Share Posted February 2, 2012 Can it be done? For example, if I want to create a function that accept any number of parameters, from three to a thousand, is there a way to do it, well, elegantly? Link to comment Share on other sites More sharing options...
hannes08 Posted February 2, 2012 Share Posted February 2, 2012 I'd suggest to pass an array as parameter. Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler] Link to comment Share on other sites More sharing options...
water Posted February 2, 2012 Share Posted February 2, 2012 In my OutlookEX UDF I use the following approach: You can pass up to 10 parameters to a function. If you need more you pack them into an array and pass the array as parameter one. The code looks like: expandcollapse popup; #FUNCTION# ==================================================================================================================== ; Name ..........: _OL_DistListMemberAdd ; Description ...: Adds one or multiple members to a distribution list. ; Syntax.........: _OL_DistListMemberAdd($oOL, $vOL_Item, $sOL_StoreID, $vOL_P1 = ""[, $vOL_P2 = ""[, $vOL_P3 = ""[, $vOL_P4 = ""[, $vOL_P5 = ""[, $vOL_P6 = ""[, $vOL_P7 = ""[, $vOL_P8 = ""[, $vOL_P9 = ""[, $vOL_P10 = ""]]]]]]]]]) ; Parameters ....: $oOL - Outlook object returned by a preceding call to _OL_Open() ; $vOL_Item - EntryID or object of the distribution list item ; $sOL_StoreID - StoreID where the EntryID is stored. Use the keyword "Default" to use the users mailbox ; $vOL_P1 - Member to add to the distribution list. Either a recipient object or the recipients name to be resolved ; + or a zero based one-dimensional array with unlimited number of members ; $vOL_P2 - Optional: member to add to the distribution list. Either a recipient object or the recipients name to be resolved ; $vOL_P3 - Optional: Same as $vOL_P2 ; $vOL_P4 - Optional: Same as $vOL_P2 ; $vOL_P5 - Optional: Same as $vOL_P2 ; $vOL_P6 - Optional: Same as $vOL_P2 ; $vOL_P7 - Optional: Same as $vOL_P2 ; $vOL_P8 - Optional: Same as $vOL_P2 ; $vOL_P9 - Optional: Same as $vOL_P2 ; $vOL_P10 - Optional: Same as $vOL_P2 ; Return values .: Success - Distribution list object ; Failure - Returns 0 and sets @error: ; |1 - No distribution list item specified ; |2 - Item could not be found. EntryID might be wrong ; |3 - Error adding member to the distribution list. @extended = number of the invalid member (zero based) ; |4 - Member name could not be resolved. @extended = number of the invalid member (zero based) ; Author ........: water ; Modified.......: ; Remarks .......: $vOL_P2 to $vOL_P10 will be ignored if $vOL_P1 is an array of members ; Related .......: ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func _OL_DistListMemberAdd($oOL, $vOL_Item, $sOL_StoreID, $vOL_P1, $vOL_P2 = "", $vOL_P3 = "", $vOL_P4 = "", $vOL_P5 = "", $vOL_P6 = "", $vOL_P7 = "", $vOL_P8 = "", $vOL_P9 = "", $vOL_P10 = "") Local $oOL_Recipient, $aOL_Recipients[10] If $vOL_Item = "" Then Return SetError(1, 0, 0) If Not IsObj($vOL_Item) Then $vOL_Item = $oOL.Session.GetItemFromID($vOL_Item, $sOL_StoreID) If @error <> 0 Then Return SetError(2, @error, 0) ; Move members into an array If Not IsArray($vOL_P1) Then $aOL_Recipients[0] = $vOL_P1 $aOL_Recipients[1] = $vOL_P2 $aOL_Recipients[2] = $vOL_P3 $aOL_Recipients[3] = $vOL_P4 $aOL_Recipients[4] = $vOL_P5 $aOL_Recipients[5] = $vOL_P6 $aOL_Recipients[6] = $vOL_P7 $aOL_Recipients[7] = $vOL_P8 $aOL_Recipients[8] = $vOL_P9 $aOL_Recipients[9] = $vOL_P10 Else $aOL_Recipients = $vOL_P1 EndIf ; Rest of the function My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Quinch Posted February 2, 2012 Author Share Posted February 2, 2012 I'd suggest to pass an array as parameter.Eh, I spoze it'll have to do. Thanks, though. Link to comment Share on other sites More sharing options...
Juvigy Posted February 2, 2012 Share Posted February 2, 2012 Why not use CMD parameters?Note : only 63 parameters can be return by $CmdLine[...], but $CmdLineRaw will always returns the entire command line.So if they are more then 63 - you can use $CmdLineRaw and split it manually Link to comment Share on other sites More sharing options...
hannes08 Posted February 2, 2012 Share Posted February 2, 2012 Why not use CMD parameters? Note : only 63 parameters can be return by $CmdLine[...], but $CmdLineRaw will always returns the entire command line. So if they are more then 63 - you can use $CmdLineRaw and split it manually He's been talking about internal functions, right? Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler] Link to comment Share on other sites More sharing options...
czardas Posted February 2, 2012 Share Posted February 2, 2012 Some of my allow up to 100 values to be sent to the function. I could have used an array, but chose not to do so. I don't know if there is a limit to the number of parameters you can pass to a function. operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now