Jump to content

Question about using ptr()


Recommended Posts

So lately I've just been playing around with arrays and the struct associated functions built into autoit just for fun and as a learning experience.   

So this has all kinda brought me to the ptr() function.   It seems simple enough.   My only real question about it is there anyway to read the data contained in the pointer without it being inside of a struct?  

I haven't really had time to play around with it.  Last night I was playing around with creating structs in autoit which just seems overly complicated.  I really only say that bc of the need to define each variable type and name b4 its able to be created.   I guess its possible to make this dynamic.  I guess I need more time to wrap my mind around it.  I'd have thought someone would have made a wrapper for the existing struct functions to make them easier to use.  

Edited by markyrocks
Duh
Link to comment
Share on other sites

Hello. Ptr is not a function to return a pointer of a variable. 

So the answer to your first question is no.

You don't need to define field name in dllstructures(But It's better to have a name when you work with long structures etc) You just can define data type.

 

 

Saludos

 

Link to comment
Share on other sites

15 minutes ago, Danyfirex said:

Hello. Ptr is not a function to return a pointer of a variable. 

So the answer to your first question is no.

You don't need to define field name in dllstructures(But It's better to have a name when you work with long structures etc) You just can define data type.

 

 

Saludos

 

So if ptr() is not meant to return a pointer to a variable data memory address then what is its purpose exactly?  I'm not well versed in pointers or even what traditional pointers are used for.  I just can't wrap my mind around  how this... $ptr=prt(1) could be useful.   I'd like to see an example less generic than the help file with some actual application.   

 

I've definitely done some soul searching in regards to the included struct creation functions.  I'm almost an expert,  not quite lol.  But I am actually working on a wrapper for it that you basically send a struct name and an array of variables and it figures out what the data types are the sizes ect.  Its actually working I just have to play around with it some more.  One thing I really didn't test was how or even if its possible to store an array inside of a data element in the struct.  And I'm not referring to the way that the struct handles a string as an array.  

Link to comment
Share on other sites

Good luck with your wrapper.  It will not be obvious to manage all types of alignment between 32bits and 64bits. Especially if there are embedded struct...endstruct within structure with specific alignment indicators too.  Not sure if it is indeed doable to have a generic wrapper to generate all types of structures.  The wrapper may end up being more complex than the actual structure declaration...

Link to comment
Share on other sites

1 hour ago, Nine said:

Good luck with your wrapper.  It will not be obvious to manage all types of alignment between 32bits and 64bits. Especially if there are embedded struct...endstruct within structure with specific alignment indicators too.  Not sure if it is indeed doable to have a generic wrapper to generate all types of structures.  The wrapper may end up being more complex than the actual structure declaration...

Lol the idea is that if someone has a specific use for things like what you describe then more than likely creating the struct in the currently available format wont be an issue.   What I'm trying to accomplish is an idiot proof method that a newb can use but is good enough to be used for more complex purposes with relative ease using the most common data types.  I'm working on the basics rn, I'll move on to more complicated things like alignment ect later on.  I'll probably be posting it up tonight after I work out a few kinks.  That way others can give thoughts opinions,  test it ect.  

 

I will admit that the wrapper is very complicated lol but the call to the wrapper is simple.   _CreateStruct(by ref $StructName, $Array)  The return is the created struct with data passed to it set.  I also have it to where if a 2d array is passed then it can be formatted with the name of the element in array element $Array[$x][0], data in $Array[$x][1] that can be retrieved by my function _StructGetData("Struct.Element")  or element can be a number i.e. "Struct.1"

But again it's all working,  I did lots of testing as I was writing it.  But it all seems to store and retrieve successfully.   Tonight I'm going to button up the main functions and possibly started working on passing a 3d array that will create multiple structs.  I'm pretty excited about it.... on second thought the idea of creating multiple structs using a 3d array is probably kinda dumb.  Really doesn't seem like any real purpose when the function could just be looped however.   

Edited by markyrocks
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...