SlowCoder74 Posted April 17, 2012 Share Posted April 17, 2012 Hey all. Strange happenings here. Hoping you can help. Here's my very simple test code: $retVal = MyFunc() Func MyFunc() local $MyArr[0] EndFunc If I try to assign my local array with 0 elements, does it return "Array variable subscript badly formatted"? If I assign simply change it to $MyArr[1], it works without errors. I've even tried to assign it with 1 element, then redim it to 0 elements, and it still chokes at the redim statement. I need my array to start at 0. Link to comment Share on other sites More sharing options...
somdcomputerguy Posted April 17, 2012 Share Posted April 17, 2012 The index# of the first element starts at 0, and AFAIK, an array has to have at least one element, or else it's just a variable. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
SlowCoder74 Posted April 17, 2012 Author Share Posted April 17, 2012 Sorry, got my terms mixed up. I should have said "index" instead of "elements", because index 0 is the first element. It's getting late. I've never run into a language, apparently until now, that didn't allow an array to be dimensioned with a ubound of 0. That still allows for 1 element at index 0. Am I missing something here with AutoIT? Link to comment Share on other sites More sharing options...
Skitty Posted April 17, 2012 Share Posted April 17, 2012 Hey all. Strange happenings here. Hoping you can help. Here's my very simple test code: $retVal = MyFunc() Func MyFunc() local $MyArr[0] EndFunc If I try to assign my local array with 0 elements, does it return "Array variable subscript badly formatted"? If I assign simply change it to $MyArr[1], it works without errors. I've even tried to assign it with 1 element, then redim it to 0 elements, and it still chokes at the redim statement. I need my array to start at 0. Just curious. Why? Link to comment Share on other sites More sharing options...
SlowCoder74 Posted April 17, 2012 Author Share Posted April 17, 2012 Just curious.Why?I'm not sure what you're referring to, but I'm guessing you're talking about the "0 elements", which I updated to mean "an index of 0" in post #3. Link to comment Share on other sites More sharing options...
Skitty Posted April 17, 2012 Share Posted April 17, 2012 I'm not sure what you're referring to, but I'm guessing you're talking about the "0 elements", which I updated to mean "an index of 0" in post #3.I know.I mean I'm just curious of what use this would have. Link to comment Share on other sites More sharing options...
BrewManNH Posted April 17, 2012 Share Posted April 17, 2012 Just hang on until the next beta release, this will probably be implemented. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
jchd Posted April 17, 2012 Share Posted April 17, 2012 I've only been recently aware that AutoIt can manipulate empty arrays (arrays with no elements) and current AutoIt doesn't have any problem with them. It's just that you can't create them directly: they have to be the result of an external operation. Anyway and beyond this technicality, empty arrays are no panacea to programming and lack of them is no barrier to having things done. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
guinness Posted April 17, 2012 Share Posted April 17, 2012 Implemented in the Alpha release of AutoIt >> UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
jchd Posted April 17, 2012 Share Posted April 17, 2012 Seems like the horse is out of the barn sooner than I thought. Note that this is alpha explosive, so handle with care and no smoking around... This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted April 18, 2012 Share Posted April 18, 2012 For 1 element then write local $MyArr[1] .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
ProgAndy Posted April 18, 2012 Share Posted April 18, 2012 (edited) If you need a one dimensional array with 0 elements in the current version, you can go through an object: Func _ArrayGetEmpty() Local Static $array If IsArray($array) Return $array Local $o = ObjCreate("Scripting.Dictionary") $array = $o.Keys() Return $array EndFunc Edited April 18, 2012 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted April 18, 2012 Share Posted April 18, 2012 Guys guys, he said he wanted 1 element. First element is in 0 but array creation is 1 based, hence what I posted. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
guinness Posted April 18, 2012 Share Posted April 18, 2012 Guys guys, he said he wanted 1 element. First element is in 0 but array creation is 1 based, hence what I posted. Local $aArray[1] = [0] ; Shouldn't it be this then? UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted April 20, 2012 Share Posted April 20, 2012 Local $aArray[1] = [0] ; Shouldn't it be this then? I don't know what that is supposed to be. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Malkey Posted April 20, 2012 Share Posted April 20, 2012 I don't know what that is supposed to be. @AdmiralAlkex With a positive approach, guinness's script is obvious "what that is supposed to be". It is the same script as your posted script, post #11, together with assigning a value, "0" - a zero-based value, similar to its index. This might help. Local $aArray[1] = [0] ConsoleWrite("$aArray[0] = " & $aArray[0] & @LF) ; This (one element) array has a zero-based index. ;Returns:- ;$aArray[0] = 0 Here is an example for ProgAndy's "_ArrayGetEmpty" function relating to the threads title and to pre-post #3 - before SlowCoder74 have up on "Local $array[0]" and "ReDim $array[0]". Local $a = _ArrayGetEmpty() ; Creates an empty array (no elements). ; ConsoleWrite($a[0] & @LF) ; <-- Create error. This one dimensional array has no elements, thus, no index - a nothing-based index. MsgBox(0, "Empty array", _ "IsArray(): " & IsArray($a) & @LF & _ "No.rows: " & UBound($a) & @LF & _ "No.columns: " & UBound($a, 2) & @LF & _ "No. of dims: " & UBound($a, 0)) ReDim $a[UBound($a) + 1] ; $a has to be an array variable for ReDim to work correctly. MsgBox(0, "Empty array", _ "IsArray(): " & IsArray($a) & @LF & _ "No.rows: " & UBound($a) & @LF & _ "No.columns: " & UBound($a, 2) & @LF & _ "No. of dims: " & UBound($a, 0)) ; http://www.autoitscript.com/forum/topic/139665-assigning-a-local-array-with-0-elements/page__view__findpost__p__980047 Func _ArrayGetEmpty() Local Static $array If IsArray($array) Then Return $array ; <-- "Then" Added Local $o = ObjCreate("Scripting.Dictionary") $array = $o.Keys() Return $array EndFunc ;==>_ArrayGetEmpty Link to comment Share on other sites More sharing options...
UEZ Posted April 20, 2012 Share Posted April 20, 2012 (edited) My glass ball shows me that one of the next AutoIt releases will have empty array feature... -> Dim $array[0] Br, UEZ Edited April 20, 2012 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
ProgAndy Posted April 20, 2012 Share Posted April 20, 2012 My glass ball shows me that one of the next AutoIt releases will have empty array feature...Thats why I wrote "in the current autoit release" *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted April 20, 2012 Share Posted April 20, 2012 @Malkey Yeah but I don't see where anyone said anything about any value. @SlowCoder74 Why don't you stop trolling and confirm something before we all go mad! .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
SlowCoder74 Posted April 25, 2012 Author Share Posted April 25, 2012 Guys guys, he said he wanted 1 element. First element is in 0 but array creation is 1 based, hence what I posted.Yes, this is exactly what I'm saying. 0-based array, but AutoIT doesn't seem to (currently) support it. Typically data can be stored at [0] in other languages. If this is not doable at this time, I'm sure I can find a way around it. @SlowCoder74 Why don't you stop trolling and confirm something before we all go mad! LOL! I just got back here to read all of your responses. 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