Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

The key of associative array automatic be modified.



  • Please log in to reply
2 replies to this topic
magusneo
  • Members
  • 51 posts
  • Last active: May 10 2014 03:15 PM
  • Joined: 30 May 2012
oMDCTP:=new CTPMDclass()
oMDCTP.Subscribe("6000.SS")
oMDCTP.Subscribe("6635.SS")
oMDCTP.Subscribe("6055.SS")

for k,v in oMDCTP.MDarray
MsgBox,% k ":" v


class CTPMDclass{
	static MDarray:={}
	Subscribe(ByRef Instrument){
		StringSplit,strarr,Instrument,.
		OutputDebug,% strarr1
		;this.MDarray.Insert(strarr1 . "",1)
		this.MDarray.Insert(strarr1,1)
	}
}

It should display "6000:1","6635:1","6055:1",but it display "6000:1","6636:1","6055:1" instead.

I'm using AHK_L 1.1.13.



strobo
  • Members
  • 359 posts
  • Last active: Mar 10 2015 08:13 PM
  • Joined: 19 Jun 2012
✓  Best Answer

AHK auto-increments positive integer keys when using .insert, afaik. Try foo[i] := bar instead.


Regards,
Babba

magusneo
  • Members
  • 51 posts
  • Last active: May 10 2014 03:15 PM
  • Joined: 30 May 2012

Ok,Thanks.