Tyranna Posted August 7, 2017 Share Posted August 7, 2017 (edited) Is there a way to extract the element names and data type definitions from a DllStruct? I have a DLLStruct with many elements and would like to set up an array that has the Datatype and element name to display them on a generically created set of controls. But I need to be able to insert an entry in the DLLStruct definition when I want to, and then, not have to go back and renumber the array that is now out of order. So what I want is to read the DLLStruct data and name by index. Then load those values into the generic table. (The table consisting of labels and input boxes created in order so I can use an index value on them) I suppose I could get the value, and use a GetVarType on it , but the element NAME string is what I define the element as and make reference to, so I would like to be able to get that name. And, is there a way to get the number of elements in the struct? Like a Ubound function for DLLStructs... Edited August 7, 2017 by Tyranna Link to comment Share on other sites More sharing options...
jchd Posted August 7, 2017 Share Posted August 7, 2017 (edited) I've writen a function that might help a bit but it doesn't actually cover all your bases, mainly as it doesn't even try to detect and output alignment directives, including STRUCT and ENDSTRUCT. That is [painfully] possible but would require a whole lot of new code for what I consider mostly corner cases. This quick'n'dirty code requires the beta in order to support Map datatype. There is no possibility with current AutoIt to recover structure field names, but they are essentially cosmetic. In your case, setting up a 2D array to store field name along with a float to be able to insert betwwen existing entries + sort on that column before re-creation would do. Won't work forever but a double has enough precision to be workable. VarDump.au3 Needless to say, all this is experimental at best, buggy most probably. Edited August 7, 2017 by jchd 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...
Tyranna Posted August 7, 2017 Author Share Posted August 7, 2017 Hmm. That is some crazy coding to determine what the elements are. This seems to imply that if you want to know what element you want, you have to memorize the struct definition itself. That simply cannot happen. Especially if the structure definition is changing when new entries are added or deleted. The Idea of adding a sort column is cool, but the definition is already in place and I cant(wont) change the mile long thing. I did have an idea though, and it goes something like this: 1.) Store the Struct Elements and Types fields in a CSV file. Ex: LINE1: "BYTE" , "ELEMENT1[20]" 2.) Parse those into an array using 1-based index and 0 being the total elements in the struct 3. ) Create the struct definition from the array entries with concatenation. Then maybe I could just go to the file and add an entry where ever I wanted to and could read the ELEMENTNAME from the array. Then the Array element number could match the index of the Struct as well Creating the original file would be very tedious work..... What do you think? Link to comment Share on other sites More sharing options...
jchd Posted August 7, 2017 Share Posted August 7, 2017 28 minutes ago, Tyranna said: This seems to imply that if you want to know what element you want, you have to memorize the struct definition itself. That simply cannot happen. Ahem, this is just what you do in the 1) 2) 3) points in your post. I suggested an all-embedded way to do it. Relying on reading/editing of an external file wasn't in the original landscape, at least as I viewed it. And yes, I had "some" fun dumping actual precise content of variables. May I ask why you need such dynamically changing C structures? 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...
Tyranna Posted August 7, 2017 Author Share Posted August 7, 2017 I would have to respectfully disagree with the assessment that that is what i was doing in step 1,2, and 3. Because, at that point I can link the elementname with the index of the struct. I do not want to have to go look at the struct definition every time I want to know the element name or vice versa. I want to use the element name to derive the struct index. I can access the struct with the name, or index, but to a loop outputting formatted output, it cant see the name at all. I would end up with a list of data labeled 1,2,3,4,5,6,7,8 etc, which when all the data is numbers, would mean nothing when displayed in table format. That is why I want to get the name, so I can display the elements data and its corresponding name(Label) I suppose i am using a struct as a database. Maybe that's not a proper implementation for a database. But, since the DLLStruct has that elementname parameter that you can use to access the specific struct data it seemed to me, in my mind a perfect fit. At least until I found that I can't use the elementname. Obviously somewhere in AutoIt there is a mapping from the struct elementname to the struct index, because it maps it to it in the DLLStructGetData command. It was an intuitive leap that I would be able to access that mapping somewhere. Link to comment Share on other sites More sharing options...
RTFC Posted August 8, 2017 Share Posted August 8, 2017 A different suggestion. My Contributions and Wrappers Spoiler BitMaskSudokuSolver BuildPartitionTable CodeCrypter CodeScanner DigitalDisplay Eigen4AutoIt FAT Suite HighMem MetaCodeFileLibrary OSgrid Pool RdRand SecondDesktop SimulatedAnnealing Xbase I/O Link to comment Share on other sites More sharing options...
Tyranna Posted August 8, 2017 Author Share Posted August 8, 2017 That post makes no sense to me, and DllStructAnylyze appears to be an undefined function. I do not know if that is UDF, or an #INCLUDE or what. Link to comment Share on other sites More sharing options...
spudw2k Posted August 8, 2017 Share Posted August 8, 2017 (edited) The DllStructAnalyze and supporting functions are in the spoiler (Reveal hidden contents) of Ward's first post. His example crashes though, at least when I tried executing it. Has potential though. Edited August 8, 2017 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Tyranna Posted August 10, 2017 Author Share Posted August 10, 2017 Well, I implemented the file method with an asscociated array for referencing the elementname and it works well. It is a round-about, but I can edit the file, and it re-creates the Struct by concatenating the array elements. 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