wish: function overloading Topic is solved

Propose new features and changes
User avatar
SL5
Posts: 879
Joined: 12 May 2015, 02:10
Contact:

wish: function overloading

18 Feb 2019, 02:50

for example i have this toolTipGui and want to overloaden it with different operators (compare: https://en.wikipedia.org/wiki/Function_overloading#Rules_in_function_overloading )

Code: Select all

toolTipGui(text, crosshair := "", hiddenTitle := "", bgColor := "", fontSize := 0, MonitorNr :=0){
	return toolTipGui(text, x := 1, y := 1, crosshair , hiddenTitle , bgColor , fontSize , MonitorNr )
}

toolTipGui(text, x := 1, y := 1, crosshair := "", hiddenTitle := "", bgColor := "", fontSize := 0, MonitorNr :=0){
...
ok, only way is probably now to use array or objects as parameters.
User avatar
SL5
Posts: 879
Joined: 12 May 2015, 02:10
Contact:

Re: wish: function overloading  Topic is solved

18 Feb 2019, 03:53

i thought about it. Oops . i thinks it possible.

with RegExMatch(x,"\d") i proof the parameter type. if its string or a number.
i have forget that if is all only untyped parameters, its not compareable to this style: https://en.wikipedia.org/wiki/Function_overloading#Rules_in_function_overloading

Code: Select all

toolTipGui(text, x := 1, y := 1, crosshair := "", hiddenTitle := "", bgColor := "", fontSize := 0, MonitorNr :=0){
	; also possible usage: 
	; toolTipGui(text, crosshair := "", hiddenTitle := "", bgColor := "", fontSize := 0, MonitorNr :=0)
	; example: toolTipGui("hi world ", crosshair := "|-")
isXcrosshair := (x && !RegExMatch(x,"\d"))
if(isXcrosshair) ;  Determines if x is not a number whether a string contains a pattern (regular expression).
{
	crosshair := x
	x := 1
	
	
	if(y)
		hiddenTitle := y
	
	if(bgColor)		
		MonitorNr := bgColor
	
	if(crosshair)
		bgColor := crosshair
	
	if(hiddenTitle)
		fontSize := hiddenTitle
	
	if(crosshair)
		bgColor := crosshair
		y := 1
}
else
if(y && !RegExMatch(y,"\d")) ;  Determines if x is not a number whether a string contains a pattern (regular expression).
{
	if(fontSize)
		MonitorNr := fontSize
	if(bgColor)
		fontSize := bgColor
	if(hiddenTitle)
		bgColor := hiddenTitle
	if(crosshair)
		hiddenTitle := crosshair
	crosshair := y
		; hiddenTitle := y
	y := (x) ? x : 1
	x := 1
		; pause
}
if(!y)
	y := 1
....

Return to “Wish List”

Who is online

Users browsing this forum: No registered users and 47 guests