Jump to content
Sign in to follow this  
johnmcloud

[SOLVED] For...Next Question

Recommended Posts

johnmcloud

Hi all,

A fast question, i need to make a For...Next, like this:

For $x = 1 To 6
MsgBox(0,0, $x)
Next

But i want to make a version with zero like this:

01
02
03
...
09
10
11

and one like this:

001
002
003
...
009
010
011
...
099
100

I have try to make the 0 before the variable but i have 010 011 in the first version and 0010 0011 in the second.

Some suggestion?

Thanks

Edited by johnmcloud

Share this post


Link to post
Share on other sites
PhoenixXL

try using

StringFormat


My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites
PhoenixXL

Somewhat like this

$NoOfZeroes = 2
For $x = 1 To 6
MsgBox(64, @ScriptName & ' | Phoenix XL', StringFormat('%0' & $NoOfZeroes & 'i', $x))
Next


My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites
johnmcloud

Yes, thanks ;)

I have a side-question for this, i want to apply that to a function for enable-disable checkbox

Local $Checkbox_

 
$Checkbox_01 = GUICtrlCreateCheckbox("", 300, 101, 65, 17)
$Checkbox_02 = GUICtrlCreateCheckbox("", 310, 101, 65, 17)
$Checkbox_03 = GUICtrlCreateCheckbox("", 320, 101, 65, 17)
$Checkbox_04 = GUICtrlCreateCheckbox("", 330, 101, 65, 17)
$Checkbox_05 = GUICtrlCreateCheckbox("", 340, 101, 65, 17)
$Checkbox_06 = GUICtrlCreateCheckbox("", 350, 101, 65, 17)

$NoOfZeroes = 2
For $x = 1 To 6
GUICtrlSetState($Checkbox_ & StringFormat('%0' & $NoOfZeroes & 'i', $x))
Next

But not work, tips?

Thanks

Share this post


Link to post
Share on other sites
PhoenixXL

you are getting confused

try looking at the Eval function


My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites
PhoenixXL

Somewhat like this

#include <GuiConstants.au3>

GUICreate('')
$Checkbox_1 = GUICtrlCreateCheckbox("", 300-40, 101, 65, 17)
$Checkbox_2 = GUICtrlCreateCheckbox("", 310-35, 121, 65, 17)
$Checkbox_3 = GUICtrlCreateCheckbox("", 320-30, 141, 65, 17)
$Checkbox_4 = GUICtrlCreateCheckbox("", 330-25, 161, 65, 17)
$Checkbox_5 = GUICtrlCreateCheckbox("", 340-20, 181, 65, 17)
$Checkbox_6 = GUICtrlCreateCheckbox("", 350-15, 201, 65, 17)

$NoOfZeroes = 2
For $x = 1 To 6
GUICtrlSetState(Eval('Checkbox_' & $x), $GUI_CHECKED)
Next
GUISetState()

While GUIGetMsg()<>-3
Sleep(10)
WEnd


My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites
johnmcloud

I dind't know the Eval function, but like this:

$NoOfZeroes = 2
For $x = 1 To 6
GUICtrlSetState(Eval("$Checkbox_" & StringFormat('%0' & $NoOfZeroes & 'i', $x)), $GUI_CHECKED)
Next

Seems not work

EDIT: My mistake, work ;)

I have put the $

Wrong:

Eval("$Checkbox_"

Correct:

Eval("Checkbox_"
Edited by johnmcloud

Share this post


Link to post
Share on other sites
johnmcloud

My really last question about For...Next

In a scenario like:

IniWrite("Test, "MyKey", "17", "7")
IniWrite("Test, "MyKey", "18", "8")
IniWrite("Test, "MyKey", "19", "9")
IniWrite("Test, "MyKey", "20", "10")
IniWrite("Test, "MyKey", "21", "11")
IniWrite("Test, "MyKey", "22", "12")

How i can concatenate the two For...Next?

Thanks for your time PhoenixXL

Share this post


Link to post
Share on other sites
PhoenixXL

If there is a sequence of the Numbers use it inside the Loop

orelse make an Array and execute the Functions using the Index

Example

#include <GuiConstants.au3>

GUICreate('')
$Checkbox_1 = GUICtrlCreateCheckbox("", 300 - 40, 101, 65, 17)
$Checkbox_2 = GUICtrlCreateCheckbox("", 310 - 35, 121, 65, 17)
$Checkbox_3 = GUICtrlCreateCheckbox("", 320 - 30, 141, 65, 17)
$Checkbox_4 = GUICtrlCreateCheckbox("", 330 - 25, 161, 65, 17)
$Checkbox_5 = GUICtrlCreateCheckbox("", 340 - 20, 181, 65, 17)
$Checkbox_6 = GUICtrlCreateCheckbox("", 350 - 15, 201, 65, 17)
Local $nArray[6][2] = [ ["17","7"], _
["18","8"], _
["19","9"], _
["20","10"], _
["21","11"], _
["22","12"] _
]
$NoOfZeroes = 2
For $x = 1 To 6
GUICtrlSetState(Eval("$Checkbox_" & StringFormat('%0' & $NoOfZeroes & 'i', $x)), $GUI_CHECKED)
IniWrite("Test.ini", "MyKey",$nArray[$x-1][0],$nArray[$x-1][1])
Next
GUISetState()
While GUIGetMsg() <> -3
Sleep(10)
WEnd

Use Tidy[CTRL + T] to make the Syntax look Clean ;)

Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites
johnmcloud

Are two sequence of number, so i think i can avoid to write every number in the array

EDIT: This time i have resolved by myself

Static $iCount = 10
For $x = 1 To 6
 $iCount += 1
 ConsoleWrite($x & " " & $iCount & @CRLF)
Next

Thanks again ;)

Edited by johnmcloud

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  

  • Similar Content

    • MrCheese
      By MrCheese
      Hi guys,
       
      Wondering, is there a better way, likely to use 'for...next' to add a letter to each range, by moving right -> along a range of columns in excel.
      I currently use this, but its clunky.
      If $run = 1 Then $range = "B6:B41" If $run = 2 Then $range = "C6:C41" If $run = 3 Then $range = "D6:D41" If $run = 4 Then $range = "E6:E41" If $run = 5 Then $range = "F6:F41" If $run = 6 Then $range = "G6:G41" If $run = 7 Then $range = "H6:H41" If $run = 8 Then $range = "I6:I41" If $run = 9 Then $range = "J6:J41" If $run = 10 Then $range = "K6:K41" If $run = 11 Then $range = "L6:L41" If $run = 12 Then $range = "M6:M41" If $run = 13 Then $range = "N6:N41" If $run = 14 Then $range = "O6:O41" If $run = 15 Then $range = "P6:P41" If $run = 16 Then $range = "Q6:Q41" If $run = 17 Then $range = "R6:R41" If $run = 18 Then $range = "S6:S41" If $run = 19 Then $range = "T6:T41" If $run = 20 Then $range = "U6:U41" If $run = 21 Then $range = "V6:V41" If $run = 22 Then $range = "W6:W41" If $run = 23 Then $range = "X6:X41" If $run = 24 Then $range = "Y6:Y41" If $run = 25 Then $range = "Z6:Z41" If $run = 26 Then $range = "AA6:AA41" If $run = 27 Then $range = "AB6:AB41" If $run = 28 Then $range = "AC6:AC41" If $run = 29 Then $range = "AD6:AD41" If $run = 30 Then $range = "AE6:AE41" If $run = 31 Then $range = "AF6:AF41" If $run = 32 Then $range = "AG6:AG41" If $run = 33 Then $range = "AH6:AH41" If $run = 34 Then $range = "AI6:AI41" If $run = 35 Then $range = "AJ6:AJ41" If $run = 36 Then $range = "AK6:AK41" If $run = 37 Then $range = "AL6:AL41" If $run = 38 Then $range = "AM6:AM41" If $run = 39 Then $range = "AN6:AN41" If $run = 40 Then $range = "AO6:AO41" If $run = 41 Then $range = "AP6:AP41" If $run = 42 Then $range = "AQ6:AQ41" If $run = 43 Then $range = "AR6:AR41" If $run = 44 Then $range = "AS6:AS41" If $run = 45 Then $range = "AT6:AT41" If $run = 46 Then $range = "AU6:AU41" If $run = 47 Then $range = "AV6:AV41" If $run = 48 Then $range = "AW6:AW41" If $run = 49 Then $range = "AX6:AX41" If $run = 50 Then $range = "AY6:AY41"  
      Normally, if it was going down the rows, i'd use this:
       
      For $i = 0 To UBound($iRowCount) - 1 $row = $i + 1 $range = "B"&$row&":B"&$row+1 Next  
      so something like this, but i don't know how to code sequential columns:
      For $i = 0 To UBound($iColCount) - 1 $col = $i + 1 $range = $col&"1:"&$col&"40" Next  
      If I don't make sense, let me know.
      Any help would be great. thanks
    • nacerbaaziz
      By nacerbaaziz
      hellow guys
      I am a blind young man
      I started a project to make an audio player
      with recorder
      I ended the player and i did not know how to recorder
      This player is Compatible with the blind and visually impaired and ordinary users
      Unfortunately I do not see so I could not merge images and icons
      So I hope you will be able to help me in this matter
      I will bring you the open source project and please help me to add images, icons and recorder, the project is requires easy access in order to be compatible with the screen readers, Please take this into account.
      the software is organized so the recorder is In a special  menu that Contains stop and start and pause and save.
      The same is true for player
      Please help
      And greetings to all
      easy player.zip
    • nlta1992
      By nlta1992
      I want creat GUI, have button 1 to 10, but only use loop for ... to ... step ... next.
      Thanks.
    • digitalexpl0it
      By digitalexpl0it
      Hello,
       
      I am trying to updated a autoit app that moves files from one location to another. What Ia m trying to do is exclude specified sub directories from being moved/copied or files within the sub-folders
      As of now the code doesn't want to execute the nested for loop 
       
      Global $szDrive, $szDir, $szFName, $szExt Global $File = "*" func File_mover($Src,$File,$Dst) ; GET DIRECTORY EXCLUDES ; ###################### ; Create blank 2 dem array Local $ExArray[0][1] ; load ini file Local Const $sFilePath = "exclude.ini" ; Check to see if ini exists Local $iFileExists = FileExists($sFilePath) ; If the INI file is not found, output error message If not $iFileExists Then msgbox(0,"Oh NO!", $sFilePath & " not found!") endif ; Read ini file Local $aArray = IniReadSection($sFilePath, "test") ; Start the array loop If Not @error Then for $i = 1 to $aArray[0][0] ; Add Ini values into array _ArrayAdd($ExArray, $aArray[$i][1]) next endif ; Display array ;_ArrayDisplay($ExArray, "test Label") ProgressOn("Moving Scanned File(s)", "Moving scans into citrix...", "0%") $aFiles = _FileListToArray3($Src, $File, 1, 1, 0, 0) For $i = 1 To $aFiles[0] call("_PathSplit",$aFiles[$i], $szDrive, $szDir, $szFName, $szExt) $SrcFile = $Src & "\" & $szDrive & $szDir & $szFName & $szExt $DstFile = $Dst & "\" & $szDir & $szFName & $szExt $NumFiles = DirGetSize($Src,1) ; If File Exsists copy and rename file If FileExists($DstFile) Then $DstFile = call("_IfIdenticalIncrement", $SrcFile, $DstFile) If $DstFile <> "" Then For $ii = $NumFiles[1] To 100 Step 10 ProgressSet($ii, $ii & "%","Moving Files...") ; Move Scans ; List Dir in srouce dir $dirEx = _FileListToArray($Src,"*",2) If UBound($dirEx) > 1 Then ; Look in the dir list array For $dir In $dirEx ; Find and compaire dir in exclude array For $exclude In $ExArray If ($dir = $exclude) Then ; if exclude dir found go to top loop and skip ContinueLoop 2 EndIf Next FileMove($SrcFile, $DstFile, 8) Next endif Sleep(100) Next EndIf ; File doesnt exists so copy the file over Else For $ii = $NumFiles[1] To 100 Step 10 ProgressSet($ii, $ii & "%","Moving Files...") ; Move Scans ; List Dir in srouce dir $dirEx = _FileListToArray($Src,"*",2) If UBound($dirEx) > 1 Then ; Look in the dir list array For $dir In $dirEx ; Find and compaire dir in exclude array For $exclude In $ExArray If ($dir = $exclude) Then ; if exclude dir found go to top loop and skip ContinueLoop 2 EndIf Next FileMove($SrcFile, $DstFile, 8) Next endif Sleep(100) next EndIf ProgressSet(100, "Scans Moved...Successfully!", "Done!") sleep(2000) ProgressOff() Next endfunc Func _IfIdenticalIncrement($vSrcFile, $vDstFile) Local $Count = 0 ; Get the modified date of the source file. $ScrVer = FileGetTime($vSrcFile, 0, 1) ; To get all elemnt of the distination file (in plan to add incremental number). call("_PathSplit",$vDstFile, $szDrive, $szDir, $szFName, $szExt) ; Loop to increment the name of the file. While FileExists($vDstFile) $Count += 1 $vDstFile = $szDrive & $szDir & $szFName & "(" & $Count & ")" & $szExt WEnd ; If file(1), it assume that is the first copy. If $Count = 1 Then Return $vDstFile ; If file(x-1) is identical then assume the file is already duplicated. ElseIf $ScrVer = FileGetTime($szDrive & $szDir & $szFName & "(" & $Count - 1 & ")" & $szExt, 0, 1) Then Return "" ; Else assume it is a new version. Else Return $vDstFile EndIf EndFunc ;==>_IfIdenticalIncrement  
       
      This part is skipped and not sure why
       
      For $exclude In $ExArray If ($dir = $exclude) Then ; if exclude dir found go to top loop and skip ContinueLoop 2 EndIf Next INI file is this
       
      [test] EXCLUDE1=test1 EXCLUDE2=test2 EXCLUDE3=test3  
    • RyukShini
      By RyukShini
      Opt("WinDetectHiddenText",1) #include <IE.au3> #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> #include <clear.au3> #include <ColorConstants.au3>; Including required files #include <GUIConstantsEx.au3> #include <file.au3> #include <string.au3> Sleep(5000) Local $emails = "email.txt" ;sets file path Local $pwd = "pwd.txt" ;sets file path Local $name = "name.txt" Local $ArrayEmail[57], $ArrayPwd[57], $ArrayName[57] ;declares array _FileReadToArray($emails, $ArrayEmail) ;converts file to array _FileReadToArray($pwd, $ArrayPwd);converts file to array _FileReadToArray($name, $ArrayName);converts file to array Local $url= "https://localhost/signup" Local $oIE = _IECreate($url, 1) $tags = $oIE.document.GetElementsByTagName("a") For $tag in $tags $class_value = $tag.GetAttribute("class") If string($class_value) = "badge-signup-email-link" Then $oCorrectObj = $tag ExitLoop EndIf Next If IsObj ( $oCorrectObj ) Then _IEAction ($oCorrectObj, "click") EndIf Local $name = _IEGetObjByName ($oIE, "fullname") Local $email = _IEGetObjByName ($oIE, "email") Local $password = _IEGetObjByName ($oIE, "password") _IEFormElementSetValue($name, $ArrayName[1]) _IEFormElementSetValue($email, "" & ++1 & $Arrayemail[1]) _IEFormElementSetValue($password, $ArrayPwd[1]) $colTags = _IETagNameGetCollection($oIE, "input") For $oTag In $colTags If $oTag.value = "Sign Up" Then sleep(15000) _IEAction($oTag, "click") _IENavigate($oIE,"javascript:void(0);") ; javascript:void is triggered. EndIf Next I coded this script and silly me forgot to create it in a loop to begin with -.-
      now I have tried While & For loop with counters and what not, but I just can't seem to get it to work.

      Could someone be of assistance?

      Thanks in advance.
×