DynaCall - change order of parameters

Ask for help, how to use AHK_H, etc.
User avatar
trismarck
Posts: 506
Joined: 30 Sep 2013, 01:48
Location: Poland

DynaCall - change order of parameters

29 Nov 2013, 15:06

AutohotkeyH Documentation wrote:You can change order of parameters using an object declaration. So in following example when calling the function first parameter is wParam and second Msg.

DynaCall("SendMessage",["t=tuitt",3,2],hwnd,WM_ACTIVATE:=0x06)

Code: Select all

dynaToken := DynaCall("MessageBox", "ui=tssui"
			, hwnd := 0
			, Text := "Hello"
			, title := "Title"
			, Type := 0x4000)
dynaToken.()	; works as expected

dynaToken := DynaCall("MessageBox", ["ui=tssui", 3, 2, 1, 4]
			, Text := "Hello"
			, title := "Title"
			, hwnd := 0
			, Type := 0x4000)
dynaToken.()	; order of parameters not changed
Also, what happens if I change the order of _some_ (but not all) parameters, i.e.: in the above example, if I'd use [3,2], what happens when I pass fifth and sixth parameter to DynaCall()? (are parameters, whose order was not changed, ignored, or, is there a default behavior defined for the order of _order-unspecified_ parameters? i.e. [3,2] -> [3,2,1,4].
User avatar
trismarck
Posts: 506
Joined: 30 Sep 2013, 01:48
Location: Poland

Re: DynaCall - change order of parameters

29 Nov 2013, 15:40

Right, so I've misunderstood the documentation. When I change the order of parameters, the order changes not for DynaCall(), but for the dynaToken object:

Code: Select all

;~ dynaToken := DynaCall("MessageBox", "ui=tssui"
			;~ , hwnd := 0
			;~ , Text := "Hello"
			;~ , title := "Title"
			;~ , Type := 0x4000)

dynaToken := DynaCall("MessageBox", ["ui=tssui", 3, 2, 1, 4]
			, hwnd := 0
			, Text := "Hello"	; second param
			, title := "Title"	; first param
			, Type := 0x4000)


dynaToken.("XXXXX"	; first param (the title)
		, "YYYYY")	; second param (the text)
		; works
Further tests reveal that if I don't specify indices of _all_ parameters in the parameter order array, unspecified indices are appended to the array from the smallest index to the largest index (intuitive):
  • ["ui=tssui", 3, 2] really means:
  • ["ui=tssui", 3, 2, 1, 4]

Code: Select all

;~ dynaToken := DynaCall("MessageBox", "ui=tssui"
			;~ , hwnd := 0
			;~ , Text := "Hello"
			;~ , title := "Title"
			;~ , Type := 0x4000)

dynaToken := DynaCall("MessageBox", ["ui=tssui", 3, 2]
			, hwnd := 0	; (third param)
			, Text := "Hello"	; second param
			, title := "Title"	; first param
			, Type := 0x4000) ; (fourth param)


dynaToken.("XXXXX"	; first param
		, "YYYYY"	; second param
		, 0	; third param
		, 0x3)	; fourth param

Return to “Ask For Help”

Who is online

Users browsing this forum: No registered users and 4 guests