Jump to content

Simpliest Question of the day


Go to solution Solved by water,

Recommended Posts

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)

Link to comment
Share on other sites

For $iIndex = UBound($aArray) - 1 To 0 Step -1
    ; Your code
Next

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

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 by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

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 by SorryButImaNewbie
Link to comment
Share on other sites

  • Solution

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 by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...