Sign in to follow this  
Followers 0
SorryButImaNewbie

Simpliest Question of the day

13 posts in this topic

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)

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
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?

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (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 by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#8 ·  Posted (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 by SorryButImaNewbie

Share this post


Link to post
Share on other sites

 "Houston, we  have a problem ..." ;)

What a shame sounds like a very good thread name otherwise :D

Share this post


Link to post
Share on other sites

#10 ·  Posted (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 by water
1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thanks! I was thinking about something like this along the line (hope I use this expression right) but wasn't sure about it.

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
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
Sign in to follow this  
Followers 0