HurleyShanabarger Posted February 2, 2021 Share Posted February 2, 2021 (edited) Hello, is it possible to get the datatype inside a structure giving the same result as the function VarGetType? If you take a look at his example: Dim $sStruct = "struct;boolean Test_Bool;uint Test_UInt;char Test_Char[1];endstruct" Dim $tStruct = DllStructCreate($sStruct) Dim $vBool = False ConsoleWrite("Bool by Dim: " & VarGetType($vBool) & @CRLF) DllStructSetData($tStruct, 1, False) ConsoleWrite("IsStruct?: " & VarGetType($tStruct.Test_Bool) & @CRLF) $vBool = DllStructGetData($tStruct, 1) ConsoleWrite("Bool by struct: " & VarGetType($tStruct.Test_Bool) & @CRLF) $vBool = True ConsoleWrite("Bool by assign: " & VarGetType($vBool) & @CRLF) If the variable is directly assigned the correct datatype is shown (Bool by Dim: Bool). If the value is set using DllStructSetData the returned datatype is Int32 - which I guess is the internal AutoIt representation. Is there away to receive the datatype that is actually held within the elements of the structure? Edited February 2, 2021 by HurleyShanabarger Update script Link to comment Share on other sites More sharing options...
Nine Posted February 2, 2021 Share Posted February 2, 2021 Help file says : Element Which element of the struct you want to access, starting at 1 or the element name as defined in DllStructCreate(). “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...
HurleyShanabarger Posted February 2, 2021 Author Share Posted February 2, 2021 You are right, but does not change the outcome. Link to comment Share on other sites More sharing options...
jchd Posted February 2, 2021 Share Posted February 2, 2021 (edited) Here's a way to get byte fundamental datatypes: Local $t = DllStructCreate("byte;char;wchar;short;ushort;int;uint;int64;float;double;ptr;boolean;bool") DllStructSetData($t, 1, 0x3C) DllStructSetData($t, 2, 't') DllStructSetData($t, 3, 'µ') DllStructSetData($t, 4, -12345) DllStructSetData($t, 5, 23456) DllStructSetData($t, 6, -3456789) DllStructSetData($t, 7, 4567890) DllStructSetData($t, 8, 123456789123456) DllStructSetData($t, 9, 123.456789) DllStructSetData($t, 10, 123.4567891234567) DllStructSetData($t, 11, DllStructGetPtr($t)) DllStructSetData($t, 12, True) DllStructSetData($t, 13, True) ConsoleWrite(_VarDump($t) & @LF) It has also been posted another way, using a Windows API but I don't remember which. Use search feature. Yet you can't differentiate a Boolean or a Bool from their byte or int internal representation in the structure. Dump.au3 Edited February 2, 2021 by jchd HurleyShanabarger 1 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Nine Posted February 2, 2021 Share Posted February 2, 2021 42 minutes ago, jchd said: It has also been posted another way, using a Windows API but I don't remember which. _WinAPI_DisplayStruct ? “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...
jchd Posted February 2, 2021 Share Posted February 2, 2021 Yes but this requires to supply the struct tag string to get back types. It's easier to grab struct element types by regex! Or, is the tag supplied is an empty string, then you get a useless list of bytes. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) 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