dickjones007 1 Posted November 13, 2011 i have managed to extract source link of images from a frame of a web page with this. $oMainFrame = _IEFrameGetObjByName($oIE, "topframe") ;source frame for getting picture links $oImgs = _IEImgGetCollection($oMainFrame) whats the best method of giving each of those links a unique variable name like: $image1 $image2 $image3 $image4 etc Share this post Link to post Share on other sites
Spiff59 54 Posted November 13, 2011 (edited) How about using subscripted variables (an array) and have $image[1], $image[2], etc? #include <IE.au3> #include <Array.au3> ; for testing $oIE = _IECreate ("[url="http://www.autoitscript.com/"]http://www.autoitscript.com/[/url]") $oImgs = _IEImgGetCollection ($oIE) Local $aImgs[@extended + 1] = [@extended], $iImg For $oImg In $oImgs $iImg += 1 ; $aImgs[$iImg] = $oImg.src ; full path $aImgs[$iImg] = $oImg.nameprop ; filename only Next _ArrayDisplay($aImgs) ; for testing Edited November 13, 2011 by Spiff59 1 dickjones007 reacted to this Share this post Link to post Share on other sites
dickjones007 1 Posted November 13, 2011 How about using subscripted variables (an array) and have $image[1], $image[2], etc? #include <IE.au3> #include <Array.au3> ; for testing $oIE = _IECreate ("[url="http://www.autoitscript.com/"]http://www.autoitscript.com/[/url]") $oImgs = _IEImgGetCollection ($oIE) Local $aImgs[@extended + 1] = [@extended], $iImg For $oImg In $oImgs $iImg += 1 ; $aImgs[$iImg] = $oImg.src ; full path $aImgs[$iImg] = $oImg.nameprop ; filename only Next _ArrayDisplay($aImgs) ; for testing works like a charm thank you very much Share this post Link to post Share on other sites
dickjones007 1 Posted November 14, 2011 (edited) found a problem with this first time script comes to: $aImgs[$iImg] = $oImg.src everything goes good but since it is in while 1 loop, second time script comes to that i get this: ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $aImgs[$iImg] = $oImg.src ^ ERROR ->11:54:27 AutoIT3.exe ended.rc:1 help? Edited November 14, 2011 by dickjones007 Share this post Link to post Share on other sites
dickjones007 1 Posted November 14, 2011 trace log $oImgs = _IEImgGetCollection($TopFrame) >Error code: 0 @@ Trace(297) : Local $aImgs[@extended + 1] = [@extended], $iImg >Error code: 0 @@ Trace(299) : For $oImg In $oImgs >Error code: 0 @@ Trace(301) : $iImg += 1 >Error code: 0 @@ Trace(303) : $aImgs[$iImg] = $oImg.src ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $aImgs[$iImg] = $oImg.src ^ ERROR ->13:14:28 AutoIT3.exe ended.rc:1 Share this post Link to post Share on other sites
kylomas 415 Posted November 14, 2011 dickjones007, Given that the code ran through the stmt 303 at least once we can surmise that the problem is array size exceeded. See redim in the help file ofr adding elements to an array. Hint, redim will slow you down, one common practice is to double the array size at each redim, e.g. redim $array[ubound($array) * 2] kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Share this post Link to post Share on other sites
guinness 1,518 Posted November 14, 2011 dickjones007, I would just be careful using the AutoIt site to test your code as it could land you in hot water, especially if you're checking for changes every 2ms. Though this is my interpretation of what you're doing as you've only mentioned about a while loop but not shown it. 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 Share this post Link to post Share on other sites
kylomas 415 Posted November 14, 2011 dickjones007, You are defining $aimgs to the number of returned images + 1 (assuming the the ieimggetcollection ran successfully...you probably want to check for errors here). Therefore the array boundary (ubound) will be exceed when the loop runs more than once. You may want to re-think how you are dimensioning this array and/or what you do with the images after every loop. kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Share this post Link to post Share on other sites
dickjones007 1 Posted November 14, 2011 (edited) dickjones007, Given that the code ran through the stmt 303 at least once we can surmise that the problem is array size exceeded. See redim in the help file ofr adding elements to an array. Hint, redim will slow you down, one common practice is to double the array size at each redim, e.g. redim $array[ubound($array) * 2] kylomas kylomas, would this doubling of array have any significant impact on computer mem usage if the loop ran, lets say, a 1000 times? Edited November 14, 2011 by dickjones007 Share this post Link to post Share on other sites
Spiff59 54 Posted November 14, 2011 (edited) Just change Local $aImgs[@extended + 1] = [@extended], $iImg to Local $aImgs[@extended + 1] = [@extended], $iImg = 0 Edited November 14, 2011 by Spiff59 1 dickjones007 reacted to this Share this post Link to post Share on other sites
kylomas 415 Posted November 14, 2011 (edited) dickjones007, Not really...assume 4 images are returned then... 1st loop = 4 2nd loop = 8 3rd loop = 16 4th loop = 32 5th loop = 64 as you can see the # of redims lessens as the images increase. I am assuming that you are not memory constrained??? kylomas Edit: P.S. Showing some of YOUR code would be a lot more helpfull!!! Edited November 14, 2011 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Share this post Link to post Share on other sites
dickjones007 1 Posted November 14, 2011 Just change Local $aImgs[@extended + 1] = [@extended], $iImg to Local $aImgs[@extended + 1] = [@extended], $iImg = 0 thank you for this quick help Share this post Link to post Share on other sites