Wish I would like to have Optional Parameters for Subs - Widget    Jul 14, 2016   (9 reactions) In Delphi procedures you can have default values for parameters. That means these parameters are optional. If the sub is called without these parameters, the default values will be used instead.
Why would you need this?
It allows for the creation of more flexible & intelligent Subs. Default paramet B4A Question Optional parameters? - Widget (first post)    Jul 14, 2016   (2 reactions) I think he means Subs cannot have optional parameters.
In Delphi procedures you can have default values for parameters.
The way it would look in B4A is:
'All 3 parameters have default values and are optional
sub SumAll(Value1=0 as int, Value2=0 as int, Value3=0 as int) as Int
return Value1 + Va B4A Question Raw ChatGPT class for B4X - JackKirk    Mar 14, 2023   (14 reactions) 'Uncomment this line if you want to see raw input string 'Log(chat_string) 'You can add optional parameters by just adding them to the end, e.g.: 'chat_string = "{""model"":""gpt-3.5-turbo"",""messages"": ' system_string & """},{""role"": ""user"", ""con Wish Another plea for optional parameters - NeoTechni    Aug 18, 2017   (3 reactions) I'm not sure how your code parser works, but it should be doable by: -parsing the parameter list of the function declaration to get the optional parameter's default values -when a missing/empty parameter is detected in the code that calls the function, insert the default value That way you don't hav Wish "Default Parameter Value" of a SUB - Sandman (first post)    Oct 17, 2022   (1 reaction) Now there, I don't think anyone here tried promoting "hiding parameters". That seems a bit unfair to label it as such.
It seems to me that your argument could be rephrased to "I don't like default parameters because they won't show up in the sub signature". To me, that indicates that you perhaps ha Wish Optional Parameters - LWGShane    Mar 26, 2017   (3 reactions) Has there been any updates regarding Optional Parameters for B4X? It would be a very useful feature! Wish Optional Parameters - clean up the sub, sub1, sub2 mess - rondunn (first post)    Dec 03, 2015 Not quite. That isn't an optional parameter, it is a parameter with a magic value.
Someone reading the code has to think "What is -1? Is it a real value?" when they read that function.
In my case I've got quite a few functions with 4-6 mandatory parameters, and maybe two optional parameters. Those Wish Unlimited number of arguments when using CallSub/CallSubDelayed - LucaMs (first post)    Jul 07, 2019 Thanks but, even if I agree, optional parameters are useful (sometimes), I refer to the possibility of using CallSub and CallSubDelayed with an unlimited number of arguments, which is not the same thing.
I think that this thread could be considered closed ;) Bug? Initialize2 - Sandman (first post)    Oct 28, 2020   (1 reaction) Sorry, I don't know Java so I don't know how this works. But I do use PHP quite a bit, and there we have optional parameters, like this: public function exampleFunction($name, $from = "Earth") { return "woop woop " . $name . " from " . $from; } And Python have named parameters. Bo Wish Option for All Events to Show in Log? - mmieher (first post)    Jul 24, 2022 Looks good. Optionally logging something about each parameter would be cool too. Page: 1   2   3   4   5   6   7   Powered by ColBERT |