Jump to content

Array of Structures


DreamVB
 Share

Go to solution Solved by Danyfirex,

Recommended Posts

hi, Is it possible to create an array of structures

I started yesterday to build a small lexical scanner, I am trying to build my own little toy scripting language that I will share with you all I already done the code that scans a file and breaks it up into tokens, but now I need a way to store this information I know in VB you use something like this, Example

Type TTOKEN
    TokType As Byte
    Token As Variant
End Type

Private Tokens(10) As TTOKEN

Tokens(0).TokType = 1 'cmd
Tokens(1).Token = "DIR"

Tokens(0).TokType = 2 'Num
Tokens(1).Token = 2

Is there a way to do something like this in autoit , My idea was maybe use two arrays one for TokTypes and the other for Tokens, but if there is a better way I also like to try that,

Anyway help will be very kind.

Thanks.

On Error Resume Pulling Hair Out.

Link to comment
Share on other sites

  • Solution

Hi.

Local $aArray[2]=[DllStructCreate("dword TokType;wchar Token[100]"),DllStructCreate("dword TokType;wchar Token[100]")]

$aArray[0].TokType=1
$aArray[0].Token="Hola"

$aArray[1].TokType=2
$aArray[1].Token="Mundo"

ConsoleWrite($aArray[0].TokType() & "    " & $aArray[0].Token() & @CRLF)
ConsoleWrite($aArray[1].TokType() & "    " & $aArray[1].Token() & @CRLF)

Saludos

Link to comment
Share on other sites

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