MattyD Posted July 20 Share Posted July 20 Hi all, I'll happily be shot down on this, but would it be worth bringing dot notation for structs back into the fold officially? TBH I'm not particularly married to dot notation specifically - but if its there, working, and all over the forum it might be worth revisiting. I mean there's probably little incentive to do this the correct way: SomeFunc($hSomeHandle, _ DllStructGetData($tRect, "Left"), _ DllStructGetData($tRect, "Top"), _ DllStructGetData($tRect, "Right"), _ DllStructGetData($tRect, "Bottom")) When this works perfectly fine: SomeFunc($hSomeHandle, $tRect.Left, $tRect.Top, $tRect.Right, $tRect.Bottom) Also (more of a pain point for me), it would be amazing to have a shorthand for DllStructGetPtr and DllStructGetSize. So maybe something like $tStruct.ptr if we're to continue on a theme? I feel I'm forever declaring one-off $pStruct and $iStructLen variables purely for legibility. So e.g. this ;Create Buffer $tBuffer = DllStructCreate(StringFormat("byte[%d]", $iSize)) ;create struct for a DllCall which references the buffer $tMidiHdr = DllStructCreate($tag_midihdr) $pMidiHdr = DllStructGetPtr($tMidiHdr) ;need to pass this to DllCall later! ;Set members DllStructSetData($tMidiHdr, "lpData", DllStructGetPtr($tBuffer)) DllStructSetData($tMidiHdr, "dwBufferLength", DllStructGetSize($tBuffer)) could be expressed as: $tBuffer = DllStructCreate(StringFormat("byte[%d]", $iSize)) $tMidiHdr = DllStructCreate($tag_midihdr) $tMidiHdr.lpData = $tBuffer.ptr $tMidiHdr.dwBufferLength = $tBuffer.size Just improves legibility, and is like 100x faster to code when you're doing a lot of it. Anyway, thats my thoughts FWIW. Probably just getting more irritable as I get older! Link to comment Share on other sites More sharing options...
Nine Posted July 20 Share Posted July 20 I am using a lot of the dot notation on structures. It is a bit slower than its function counterpart, but if it not use within a large loop, the difference is insignificant. I do not agree with your suggestion of .ptr and .size cause it will interfere with some structure declaration like this one (making it script breaking) : Local $tStruct = DllStructCreate("int size;long_ptr ptr") However I do think the priority should be to fix the following bug : Local $tStruct = DllStructCreate("byte data[10]") Local $i = 5 $tStruct.data(5) = 1 ; working ConsoleWrite($tStruct.data(5) & @CRLF) $tStruct.data($i) = 2 ; not working == dangerous bug ConsoleWrite($tStruct.data(5) & @CRLF) $tStruct.data(($i)) = 3 ; working ConsoleWrite($tStruct.data(5) & @CRLF) argumentum 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) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
MattyD Posted July 20 Author Share Posted July 20 (edited) 3 hours ago, Nine said: I do not agree with your suggestion of .ptr and .size cause it will interfere... sure, I'm not dying on this hill - but a shorthand any form was more what I was driving at. yep, agree that the array bug would be the first thing to fix. It's technically not a feature though hey? - I'd imagine a decision would first need to be made to pursue this at some level. Edited July 20 by MattyD Link to comment Share on other sites More sharing options...
Popular Post jpm Posted July 21 Popular Post Share Posted July 21 Hi, already fix for next beta/release Musashi, MattyD, argumentum and 3 others 1 5 Link to comment Share on other sites More sharing options...
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