Jump to content

[SOLVED] For...Next Question


Recommended Posts

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

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

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

Link to comment
Share on other sites

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.

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

×
×
  • Create New...