NewCommer Posted October 21, 2021 Posted October 21, 2021 Hello everyone, I don't know how to describe this problem, it's generally like the picture below: $n = 1 $t = DllStructCreate('int Test[2]') $t.Test(1) = 123 MsgBox(0, 0, _ $t.Test(1) & @CRLF & _ $t.Test($n) & @CRLF & _ $t.Test(Number($n))) Why "$t.Test($n)" value is 0 Thank you.
TheXman Posted October 21, 2021 Posted October 21, 2021 The post above should answer your question. NewCommer 1 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
NewCommer Posted October 21, 2021 Author Posted October 21, 2021 Thank @TheXman Instead of declaring Local, I used Enum to declare as your advice and fixed the problem.
TheXman Posted October 21, 2021 Posted October 21, 2021 You're welcome! CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
Musashi Posted October 21, 2021 Posted October 21, 2021 @TheXman 's answer solves the problem perfectly ( @NewCommer : you should mark it as solution ). Instead of ENUM you could also use ($n+0), but this is probably not the most elegant work-around. Local $n = 1 Local $t = DllStructCreate('int Test[2]') ConsoleWrite("@error = " & @error & @CRLF) $t.Test(1) = 123 $t.Test(2) = 345 MsgBox(0, 0, _ $t.Test(1) & @CRLF & _ $t.Test($n+0) & @CRLF & _ $t.Test($n+1) & @CRLF & _ $t.Test(Number($n)) & @CRLF & _ $t.Test('1')) NewCommer 1 "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."
TheXman Posted October 21, 2021 Posted October 21, 2021 I just tried to answer the question as to why it wasn't working as expected. I made no suggestions as to how to resolve the problem. For the record, in this case, I would only use an enum if naming the indexes made sense (making the code more readable and/or easier to maintain). 😉 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
Nine Posted October 22, 2021 Posted October 22, 2021 This is a known bug : https://www.autoitscript.com/trac/autoit/ticket/3838 Musashi and NewCommer 1 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
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