Jump to content
Sign in to follow this  
Grax

Custom Data Types?

Recommended Posts

Grax

Is there anyway in AutoIT to do Custom Data Types?

I'm wanting to do something like this VB code:

Type SettingInfo
    AppID As String
    CurrentPath As String
    UserName As String
    Password As String
    ExpirationDate As Date
    UsageCount As Integer
    AccessLevel As Integer
    AllowChanges As Boolean
End Type

Dim Settings As SettingInfo

Settings.AppID = "Something"
Settings.CurrentPath ="C:\Something\"

Share this post


Link to post
Share on other sites
nobbe

no , but as a workaround you could use 1dimensional array

autoit doesnt distinguish variables, so "$i" can be integer or string or array... it becomes what you set it up to..

Share this post


Link to post
Share on other sites
enaiman

From all your code it will remain only:

Dim $AppID, $CurrentPath, $UserName, $Password, $ExpirationDate, $UsageCount, $AccessLevel, $AllowChanges

$AppID = "Something"
$CurrentPath ="C:\Something\"

As nobbe pointed out - every of these variables can hold anything: now $AppID holds a string and if your next command is $AppID = 55 + 45 you will see that the new value is 100 which is a number.

I don't feel I lose anything with this variable behaviour.


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites
nobbe

another idea may be to setup variable names with prefix

so

Type SettingInfo

AppID As String

CurrentPath As String

UserName As String

Password As String

ExpirationDate As Date

UsageCount As Integer

AccessLevel As Integer

AllowChanges As Boolean

End Type

could be

$SettingInfo_AppID =" 123"

$SettingInfo_CurrentPath = "C:\Something\"

$SettingInfo_UsageCount = 3

and so on ..

or you may even more use variables following the "Hungarian notation" to give them better naming structure

http://en.wikipedia.org/wiki/Hungarian_notation

which could maybe look like

$SettingInfo_sz_AppID =" 123"

$SettingInfo_sz_CurrentPath = "C:\Something\"

$SettingInfo_i_UsageCount = 3

Share this post


Link to post
Share on other sites
rasim

From help:

In AutoIt there is only one datatype called a Variant. A variant can contain numeric or string data and decides how to use the data depending on the situation it is being used in. For example, if you try and multiply two variants they will be treated as numbers, if you try and concatenate (join) two variants they will be treated as strings.

Share this post


Link to post
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
Sign in to follow this  

×