SorryButImaNewbie Posted November 20, 2014 Posted November 20, 2014 Hello everyone I read some older topics about arrays here, and found a really clever solution to handleing stockoverflow The user suggested that start from the top of the array, and descend till 0. Naturally one can only use this approach if he knows the exact size of the array. (luckly i do) So my question is, how can I make a variable to be a non-negativ integer? (for example Global $i) Basicly I want it to only descend till 0, but I'm not sure how is the best to go about it. How you guys usualy do this? Thanks (PS.: only posting this, cause I couldn't find this tag otherwise in the forum)
water Posted November 20, 2014 Posted November 20, 2014 For $iIndex = UBound($aArray) - 1 To 0 Step -1 ; Your code Next My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
water Posted November 20, 2014 Posted November 20, 2014 BTW: Could you please give more meaningful titles to your threads? Everyone on this forum has a question My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
SorryButImaNewbie Posted November 20, 2014 Author Posted November 20, 2014 In my code, I had some trouble with for to next (I'm a 100% sure i could have done it with it, but ended up using do until) can't i make the variable to be unable to descend beyond 0?
SorryButImaNewbie Posted November 20, 2014 Author Posted November 20, 2014 Sorry, next time I keep that in mind (wanted to name it as the tag, but somehow i thought thats not a good idea, dont know why) about the nameing. I see now that how this name isn't really informative as it should be. Is there a general problem with my thread titels or only with this one?
water Posted November 20, 2014 Posted November 20, 2014 Please post the for to next code. It should be quite easy to make it work Everything else is more complex. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
water Posted November 20, 2014 Posted November 20, 2014 (edited) Sorry, next time I keep that in mind (wanted to name it as the tag, but somehow i thought thats not a good idea, dont know why) about the nameing. I see now that how this name isn't really informative as it should be. Is there a general problem with my thread titels or only with this one? Just with this one. The thread title should give an idea what the user is asking in the tread. So you attract users who could providea solution. Most users ignore general purpose threads like "Houston, we have a problem ..." Edited November 20, 2014 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
SorryButImaNewbie Posted November 20, 2014 Author Posted November 20, 2014 (edited) I don't have a for to next code, with it i could just tell it to descend to 0. I use a do.. until and it runs till it gets a "all right" message from a popup window. I want to make it so If noone of he code in the array is good, don't crash the script with array overflow code is: If WinExists("Információ", "Elérte a maximális napi vásárlási mennyiséget! ( 2 )") Then Do WinKill("Információ", "Elérte a maximális napi vásárlási mennyiséget! ( 2 )") $i = $i - 1 ControlFocus($handle, "", "TEdit1") Send("{CTRLDOWN}v{CTRLUP}") ControlClick($handle, "", "[CLASSNN:TAdvBitBtn23]") Sleep(1000) ;WinWaitActive("Befizetés") Local $handle3 = WinGetHandle("Befizetés") ControlSend($handle3, "", "[CLASSNN:TComboBox3]", "ü{ENTER}") ControlSend($handle3, "", "[CLASSNN:TEdit5]", $arrayEuroShell[$i]) ControlClick($handle3, "", "[CLASSNN:TBitBtn2]") Sleep(1000) Until WinExists("Információ", "Sikeres jegyvásárlás!") EndIf the array is within the code wrote by myself instead of reading it in from a file,$i is the number of the last array element (global) Edited November 20, 2014 by SorryButImaNewbie
SorryButImaNewbie Posted November 20, 2014 Author Posted November 20, 2014 "Houston, we have a problem ..." What a shame sounds like a very good thread name otherwise
Solution water Posted November 20, 2014 Solution Posted November 20, 2014 (edited) Then Exit when $i < 0. If WinExists("Információ", "Elérte a maximális napi vásárlási mennyiséget! ( 2 )") Then Do WinKill("Információ", "Elérte a maximális napi vásárlási mennyiséget! ( 2 )") $i = $i - 1 If $i < 0 Then ExitLoop ControlFocus($handle, "", "TEdit1") Send("{CTRLDOWN}v{CTRLUP}") ControlClick($handle, "", "[CLASSNN:TAdvBitBtn23]") Sleep(1000) ;WinWaitActive("Befizetés") Local $handle3 = WinGetHandle("Befizetés") ControlSend($handle3, "", "[CLASSNN:TComboBox3]", "ü{ENTER}") ControlSend($handle3, "", "[CLASSNN:TEdit5]", $arrayEuroShell[$i]) ControlClick($handle3, "", "[CLASSNN:TBitBtn2]") Sleep(1000) Until WinExists("Információ", "Sikeres jegyvásárlás!") EndIf Edited November 20, 2014 by water SorryButImaNewbie 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
junkew Posted November 20, 2014 Posted November 20, 2014 (edited) Until (WinExists("Információ", "Sikeres jegyvásárlás!")) or ($i=0) Edited November 20, 2014 by junkew SorryButImaNewbie 1 FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
SorryButImaNewbie Posted November 20, 2014 Author Posted November 20, 2014 Thanks! I was thinking about something like this along the line (hope I use this expression right) but wasn't sure about it.
SorryButImaNewbie Posted November 20, 2014 Author Posted November 20, 2014 Until (WinExists("Információ", "Sikeres jegyvásárlás!")) or ($i=0) oh I can give more then one exit/end possibility? didn't know that thanks!
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