Queener

Decrement Loop

7 posts in this topic

#1 ·  Posted (edited)

If a loop increment is

For $i = 0 To 5
  MsgBox(0, "", $i)
Next

Exit

How do you write a loop decrements?

 

 

Nevermind, I was using the wrong way.

;this is the correct way
For $i = 5 To 1 Step -1
  MsgBox(0, "", $i)
Next

Exit

;I was coding it this way: :)
For $i = 1 To 5 Step -1
  MsgBox(0, "", $i)
Next

Exit

 

Edited by Queener

Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")

Share this post


Link to post
Share on other sites



The help file is your friend ;)
Set Step to a negative value.

For <variable> = <start> To <stop> [Step <stepval>]

 


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

I created a list to show data from ini file. No matter how I pull the data (Incremently or Decremently), it always display the last data on top of the rows. Am I doing something wrong?


Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")

Share this post


Link to post
Share on other sites

Hard to tell without seeing your code ;)


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

#5 ·  Posted (edited)

HotKeySet("{ESC}","_Exit")

#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <GuiButton.au3>
#include <EditConstants.au3>
#include <ListBoxConstants.au3>
#include <ComboConstants.au3>
#include <Array.au3>
#include <GuiComboBox.au3>
#include <string.au3>

$title = "Perfect Tool"

$load = GUICreate($title,278,351,-1,-1,-1,-1)
$inputList = GUICtrlCreateCombo("",18,72,239,28,-1,-1)
GUICtrlSetFont(-1,12,400,0,"MS Sans Serif")
$LConfig = GUICtrlCreatelist("",18,122,239,175,-1,$WS_EX_CLIENTEDGE)
$inputSearch = GUICtrlCreateInput("",18,24,159,29,-1,$WS_EX_CLIENTEDGE)
GUICtrlSetFont(-1,12,400,0,"MS Sans Serif")
$bSearch = GUICtrlCreateButton("Search",184,24,73,29,-1,-1)
GUICtrlSetFont(-1,12,400,0,"MS Sans Serif")
$bdel = GUICtrlCreateButton("Delete",18,308,100,30,-1,-1)
GUICtrlSetFont(-1,12,400,0,"MS Sans Serif")
$bload = GUICtrlCreateButton("Load",157,308,100,30,-1,-1)
GUICtrlSetFont(-1,12,400,0,"MS Sans Serif")
GUISetState(@SW_SHOW,$load)



;Ini Top Variables
$iniLoc = @ScriptDir & "\config.ini"

;List the Section Names on Seach combobox
$iniLoadSearchName = IniReadSectionNames($iniLoc)
$listname = ""
$listname2 = ""


  If Not @error Then
  For $i = 1 To $iniLoadSearchName[0]
$listname &= $iniLoadSearchName[$i] & "|"
  Next  
$inistring = StringTrimRight($listname, 1)
  EndIf
  


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    Case $bSearch
      GUICtrlSetData($inputlist, "")
      GUICtrlSetData($inputList,$inistring)
    Case $bdel
      reload()
    Case $bload
      Loader()
    EndSwitch
WEnd

Func Loader()
$iIndex = 0
Do
    $iIndex += 1
    $sCode = IniRead($iniLoc, "John", "Job" & $iIndex, "Error")
Until $sCode = "Error"

$iIndex = $iIndex - 1

For $n = $iIndex to 1 Step -1
GUICtrlSetData($LConfig, "Job"&$n & " = " & _
IniRead($iniLoc, GUICtrlRead($inputList), "Job"&$n, "") & " --- PayID"&$n & " = " & _
IniRead($iniLoc, GUICtrlRead($inputList), "PayID"&$n, ""))
Next

EndFunc


Func Reload()
;reload the list correctly
$inistring = StringReplace($inistring, "|" & GUICtrlRead($inputlist), "")

;ini delete time
IniDelete($iniLoc, GUICtrlRead($inputlist))

;clear the data
GUICtrlSetData($inputlist, "")

;re-populate the list
GUICtrlSetData($inputlist, $inistring)

EndFunc


Func _Check($sName = 1) ;Function to load list
guictrlsetdata($InputSearch,'')
guictrlsetdata($inputList,'')

local $hit = false


    for $1 = 1 to $iniLoadSearchName[0]
        if stringregexp($iniLoadSearchName[$1],'(?i)\Q' & $sName & '\E') then
            guictrlsetdata($inputList,$iniLoadSearchName[$1])
            $hit = True
        EndIf
    next

if $hit Then
    _GUICtrlComboBox_SetCurSel ( $inputList , 0 )  ;   set edit box to 1st in list
    ;guictrlsetdata($inputid,'ID = ' & inireadsection($inifile,guictrlread($inputsearch2))[1][1])   ;   populate ID field
    EndIf
Return

EndFunc


Func _Exit()
  Exit
EndFunc
[John]
ID=1
Computer=HI0900
Desc=Cad Design
Job1=Information Desk
PayID1=11D
Access1=HR
Job2=Register Nurse
PayID2=12D
Access2=Building B
Job3=Billing Code
PayID3=13D
Access3=Home

Look at the Loader Func. 

Edited by Queener

Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I think I know why now. It's sorted by alphabet; thats why I'm seeing it other way around... I see...

 

To solve my own issue: it's

For $n = 1 To $iIndex
GUICtrlSetData($LConfig, $n & " .Job"&$n & " = " & _
IniRead($iniLoc, GUICtrlRead($inputList), "Job"&$n, "") & " --- PayID"&$n & " = " & _
IniRead($iniLoc, GUICtrlRead($inputList), "PayID"&$n, ""))
Next

 

Edited by Queener
Solved

Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")

Share this post


Link to post
Share on other sites

:)


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

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