Jump to content

Recommended Posts

Posted

How can I loop from variable to 1 with step -1

Example:

$HCount = ClipGet()

For $i = $HCount to 1 Step -1

I have tried above but it is not working. Please help me.

  • Moderators
Posted (edited)

@Vaindam please post your whole code, as it appears you have some logic issues. This, for example, works just fine.

Local $aArray[10] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
ClipPut(UBound($aArray) - 1)
Local $sVal = ClipGet()
    For $i = $sVal To 0 Step -1
        ConsoleWrite($aArray[$i] & @CRLF)
    Next

Edit: Also moved to correct forum

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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
  • Recently Browsing   0 members

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