Jump to content

global arrays and such


Recommended Posts

how can i declare an array of unspecified size in global scope?

GLOBAL $list[]

For $xi = 1 To _FileCountLines("C:\List.txt")
        $list[$xi] = guictrlcreatemenuitem("List123")
    Next
Edited by B3TA_SCR1PT3R

[right][font="Courier New"]...Run these streets all day, I can sleep when I die.[/font] [/right]

Link to comment
Share on other sites

thx ill try that once i figure out how to fix this:

==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

$list[$xi] = guictrlcreatemenuitem("List123")

^ ERROR

i have:

dim $list[9]
....
....
....
For $xi = 1 To _FileCountLines("C:\List.txt")
        $list[$xi] = guictrlcreatemenuitem("List123")
        redim $list[$xi]
Next

[right][font="Courier New"]...Run these streets all day, I can sleep when I die.[/font] [/right]

Link to comment
Share on other sites

You don't provide enough code to really know, but two things to think about:

you Dim an array with a number representing the total elements it can hold... but array references are 0-based, so an array Dim'd for 9 elements can handle indexes 0-8 (not 1-9). You should probably change your For statement to 0 To ($numLines - 1)

In your code, you're thrashing by doing a Redim inside a loop. You can know the number of elements you need before you enter the loop and can do your Redim before you enter it.

Dale

Edit: fixed typo

Edited by DaleHohm

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Hi,

not sure about this syntax?; the array does not need redim?

$list[$xi] = guictrlcreatemenuitem("List123"); not sure about this syntax?

What is it supposed to be doing??........

#include<File.au3>

#include<Array.au3>

$file1=FileOpenDialog("Choose File", @ScriptDir, "Files (*.txt)", 1,@ScriptDir&"\AnswerFolders.txt")

dim $list[_FileCountLines($file1)+1]$list[0] =_FileCountLines($file1)+1

For $xi = 1 To _FileCountLines($file1)

;$list[$xi] = guictrlcreatemenuitem("List123"); not sure about this syntax?

$list[$xi] = $xi

Next

_ArrayDisplay($list,"")

Best, Randall Edited by randallc
Link to comment
Share on other sites

wtf you have "Posts: 201" but you know nothing about autoit ...

arrays are 0 based

dim $list[_FileCountLines("C:\List.txt")]
....
....
....
For $xi = 0 To _FileCountLines("C:\List.txt") -1
        $list[$xi] = guictrlcreatemenuitem("List123")
Next
Edited by w0uter

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

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