Jump to content

Recommended Posts

Posted

1. I would like to define customized structs (like in C) so I can refer to various info regarding an object.

For example, struct for Car

could have Model, Color, Weight.

Is there anyway to do it in Autoit?

2. Also, I saw that commands after . appear in blue (for example someCommand.otherCommand), I was wondering what are they used for.

Thank you in advance

Posted (edited)

1. Take a look at the AutoItObject UDF.

2. SciTE just highlights everything after the . in blue for .au3 files :mellow: But usually that's used for interactions with a COM object -- or an AutoIt Object using the UDF mentioned in 1.

Edited by d4ni
Posted

It looks like a bit of an overkill to my current needs, but OO was definitely on my AutoIt wishlist so I'm more then glad.

Thanks a lot!

Posted

I know it might be a little overkill, but it's the only way -- as far as I know -- to add properties to something. The something would be the object ofcourse :mellow:

Posted (edited)

You can create your own structures, see the example.

But i think it's more easy to use an 2D-array.

; === hold structure in an array
; === 1.st value holds structure definition
Local $aCarStruct[1] = ["char model[128];char color[128];int weight"]

; === create new car
ReDim $aCarStruct[UBound($aCarStruct)+1]
$aCarStruct[UBound($aCarStruct)-1] = DllStructCreate($aCarStruct[0]) ; === create structure
DllStructSetData($aCarStruct[UBound($aCarStruct)-1], 'model', 'Jaguar') ; === set values
DllStructSetData($aCarStruct[UBound($aCarStruct)-1], 'color', 'silver')
DllStructSetData($aCarStruct[UBound($aCarStruct)-1], 'weight', 1511)

ReDim $aCarStruct[UBound($aCarStruct)+1]
$aCarStruct[UBound($aCarStruct)-1] = DllStructCreate($aCarStruct[0])
DllStructSetData($aCarStruct[UBound($aCarStruct)-1], 'model', 'Carerra GT')
DllStructSetData($aCarStruct[UBound($aCarStruct)-1], 'color', 'red')
DllStructSetData($aCarStruct[UBound($aCarStruct)-1], 'weight', 1380)


; === get value
; === searching for weight of Carerra GT
For $i = 1 To UBound($aCarStruct) -1
    If DllStructGetData($aCarStruct[$i], 'model') = 'Carerra GT' Then
        MsgBox(0, 'weight', DllStructGetData($aCarStruct[$i], 'weight'))
        ExitLoop
    EndIf
Next

Edited by BugFix

Best Regards BugFix  

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
×
×
  • Create New...