B3TA_SCR1PT3R Posted November 8, 2005 Share Posted November 8, 2005 (edited) 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 November 8, 2005 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 More sharing options...
w0uter Posted November 8, 2005 Share Posted November 8, 2005 you cant. but you can use ReDim to resize it. 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 More sharing options...
B3TA_SCR1PT3R Posted November 8, 2005 Author Share Posted November 8, 2005 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") ^ ERRORi 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 More sharing options...
DaleHohm Posted November 9, 2005 Share Posted November 9, 2005 (edited) 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 November 9, 2005 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 More sharing options...
randallc Posted November 9, 2005 Share Posted November 9, 2005 (edited) 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)+1For $xi = 1 To _FileCountLines($file1) ;$list[$xi] = guictrlcreatemenuitem("List123"); not sure about this syntax? $list[$xi] = $xiNext_ArrayDisplay($list,"")Best, Randall Edited November 9, 2005 by randallc ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
w0uter Posted November 9, 2005 Share Posted November 9, 2005 (edited) 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 November 9, 2005 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now