KickStarter15 Posted November 18, 2019 Share Posted November 18, 2019 (edited) Hi Experts, Hope everyone had a great day😄... I have a small problem right now Experts concerning this error "Subscript used on non-accessible variable". All I want to know is how can I skip this error type in my For... loop... Next... code and should continue looping until end. My error: D:\WorkDIR\Tool\ArchivingTool.au3" (101) : ==> Subscript used on non-accessible variable.: For $j = 1 To $aLevel2_SubFolders[0] For $j = 1 To $aLevel2_SubFolders^ ERROR My code: For $j = 1 To $aLevel2_SubFolders[0] _DirRemove($aLevel2_SubFolders[$j], 1) GUICtrlSetData($Progress1, $j) Next If I'm not mistaken, the loop stop's because the variable is equals to 0 already, and no longer continuing the loop. I tried adding "If @error then ContinueLoop" but I think it's not the right one because still stop's the loop. From the path declared, I have 23 or more subfolders to remove from a parent folder and some were excluded in removing (was declared in separate line of my code). The problem is, when my first parent folder already has no subfolder/s to remove then my For loop stop running and flagged this error. Can I do something on that? I mean, I need to continue my deletion of subfolders even if the first parent folder is already empty or was already deleted. Please let me know if you need more explanation, thanks in advance Experts. KS15 Edited November 19, 2019 by KickStarter15 Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare. Link to comment Share on other sites More sharing options...
Danp2 Posted November 18, 2019 Share Posted November 18, 2019 Verify the variable is an array before running this section of code. See IsArray entry in the help file. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
KickStarter15 Posted November 18, 2019 Author Share Posted November 18, 2019 @Danp2, Yes, but if the variable is not an array then...? can the loop continue? please advise. Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare. Link to comment Share on other sites More sharing options...
Danp2 Posted November 18, 2019 Share Posted November 18, 2019 If it's not an array, then you need to skip that section of code to avoid the subscript error. If that doesn't meet your needs, then perhaps you need to take a step back to determine if you are attempting to fix a symptom rather that the actual problem (ie: what command is creating the array and why is it failing to do so on some occasions?) Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
KickStarter15 Posted November 18, 2019 Author Share Posted November 18, 2019 @Danp2, Yup, skipping is the way and what I did is writing a dummy array just to proceed with the loop. Well thanks for sharing IsArray indeed it solved my problem🙂. Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare. Link to comment Share on other sites More sharing options...
Nine Posted November 18, 2019 Share Posted November 18, 2019 You can use ternary op like this : For $j = 1 To IsArray($aLevel2_SubFolders) ? $aLevel2_SubFolders[0] : 0 _DirRemove($aLevel2_SubFolders[$j], 1) GUICtrlSetData($Progress1, $j) Next Leendert-Jan and KickStarter15 1 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Musashi Posted November 18, 2019 Share Posted November 18, 2019 @KickStarter15 : For completeness only : Could you please post an executable minimal script that causes the problem. This may help to identify and solve it as suggested here : 59 minutes ago, Danp2 said: ... to determine if you are attempting to fix a symptom rather that the actual problem (ie: what command is creating the array and why is it failing to do so on some occasions?) @Nine : Nice usage of the ternary operator. "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
KickStarter15 Posted November 18, 2019 Author Share Posted November 18, 2019 @Nine, Thanks, it's working👍. Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare. 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