Parsix Posted April 19, 2022 Posted April 19, 2022 Hi i need to copy struct to 2D Array but not work ==> Variable must be of type "Object".: #include <array.au3> Local Const $tagObj = "hwnd hwnd;" & _ "byte ctrlID;" & _ "wchar dir[6];" & _ "byte idBKG;" Local $oObj = DllStructCreate($tagObj) $oObj.hwnd = 0x1230 $oObj.ctrlID = 2 $oObj.dir = "left" local $aArray1[0] _arrayadd($aArray1, $oObj) Msgbox(64,"$aArray1[0].dir", $aArray1[0].dir) ;<----------------this work fine local $aArray2[0][3] _arrayadd($aArray2, "main1" & "|" & $oObj.hwnd & "|" & $oObj) Msgbox(64,"$aArray2[0][2].dir", $aArray2[0][2].dir) ;<----------------this not work , return 0 | NULL Exit
Solution OJBakker Posted April 19, 2022 Solution Posted April 19, 2022 The problem is using _arrayadd() with the delimited-string option. Your object gets converted to string and is no longer an object when extracted. Do not use delimited-string for complex datatypes. Use the array-option to avoid undesired conversions. #include <array.au3> Local Const $tagObj = "hwnd hwnd;" & _ "byte ctrlID;" & _ "wchar dir[6];" & _ "byte idBKG;" Local $oObj = DllStructCreate($tagObj) $oObj.hwnd = 0x1230 $oObj.ctrlID = 2 $oObj.dir = "left" local $aArray1[0] _arrayadd($aArray1, $oObj) MsgBox(Default, "vartype", VarGetType($aArray1[0])) Msgbox(64,"$aArray1[0].dir", $aArray1[0].dir) local $aArray2[0][3] local $aAddArray[1][3] = [["main1", $oObj.hwnd, $oObj]] _arrayadd($aArray2, $aAddArray) MsgBox(Default, "vartype", VarGetType($aArray2[0][2])) Msgbox(64,"$aArray2[0][2].dir", $aArray2[0][2].dir) Exit Parsix 1
Parsix Posted April 19, 2022 Author Posted April 19, 2022 (edited) thank you very much solved Edited April 19, 2022 by Parsix
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