Jump to content

Custom Data Types?


Grax
 Share

Recommended Posts

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\"
Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

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...