Related
Dim, UBound
Example
; ví dụ Redim
Dim $I, $K, $T, $MSG
Dim $X[4][6], $Y[4][6]
For $I = 0 To 3
For $K = 0 To 5
$T = Int(Random(20) + 1) ;gán giá trị ngẫu nhiên giữa 1~20 cho các phần tử
$X[$I][$K] = $T
$Y[$I][$K] = $T
Next
Next
ReDim $X[3][8]
Dim $Y[3][8]
$MSG = ""
For $I = 0 To UBound($X, 1) - 1
For $K = 0 To UBound($X, 2) - 1
If $K > 0 Then $MSG = $MSG & ", "
$MSG = $MSG & $X[$I][$K]
Next
$MSG = $MSG & @CR
Next
MsgBox(0, "ReDim Demo", $MSG)
$MSG = ""
For $I = 0 To UBound($Y, 1) - 1
For $K = 0 To UBound($Y, 2) - 1
If $K > 0 Then $MSG = $MSG & ", "
$MSG = $MSG & $Y[$I][$K]
Next
$MSG = $MSG & @CR
Next
MsgBox(0, "ReDim Demo", $MSG)
Keyword Reference
Select Case EndSelect
cấu trúc rẽ nhiều nhánh
Select
Case <expression1>
statement1
[Case <expression2>
statement2
]
[Case Else
statementN
]
EndSelect
Parameters
Case
<expression>
biểu thức
Remarks
nếu <expression1> đúng thì làm statement1 rồi thoát khỏi cấu trúc select
nếu sai thì nếu <expression2> đúng thì làm statement2 rồi thoát khỏi cấu trúc
select
nếu sai hết thì làm statementN nếu có
Related
If Then, If Else EndIf, Switch EndSwitch, ContinueCase
Example
$var = 0
$var2= ""
Select
Case $var = 1
MsgBox(0, "", "điều kiện thứ nhất đúng")
Case $var2 = "test"
MsgBox(0, "", "điều kiện thứ hai đúng")
Case Else
MsgBox(0, "", "không điều kiện nào đúng!")
EndSelect
Keyword Reference
Switch Case EndSwitch
cấu trúc rẽ nhiều nhánh
Switch <expression>
Case <value> [To <value>] [,<value> [To <value>] ]
statement1
[Case <value> [To <value>] [,<value> [To <value>] ]
statement2
]
[Case Else
statementN
]
EndSwitch
Parameters
<expression>
biểu thức
<value> To
<value>
miền giá trị
<value> giá trị
Remarks
b1: tính giá trị của <expression>
b2: kiểm tra các value của từng case nếu đúng ở case nào thì làm statement ở case
đó rồi thoát khỏi cấu trúc switch
b3: nếu làm statementN (nếu có)
Related
If Then, If Else EndIf, Select EndSelect, ContinueCase
Example
Switch @HOUR ;lấy giờ của hệ thống
Case 6 To 11
$msg = "chào buổi sáng"
Case 12 To 17
$msg = "chào buổi chiều"
Case 18 To 21
$msg = "chào buổi tối"
Case Else
$msg = "bạn đang làm gì vào đêm khuya thế này mà chưa đi ngủ :|"
EndSwitch
MsgBox(0, Default, $msg)
Keyword Reference
False / True
Boolean giá trị cho sử dụng trong biểu thức logic
$var = False
$var = True
Parameters
None.
Remarks
?
Related
Example
$bool= False
if NOT $bool = true Then Msgbox(0,"Bool comparison", "OK")
Keyword Reference
With EndWith
đại diện cho đối tượng
With <expression>
statements
EndWith
Parameters
expression phải là một đối tượng
Remarks
?
Related
For In Next
Example
$oExcel = ObjCreate("Excel.Application")
$oExcel.visible =1
$oExcel.workbooks.add
With $oExcel.activesheet
.cells(2,2).value = 1
.range("A1:B2").clear
EndWith
$oExcel.quit
Keyword Reference
While WEnd
cấu trúc lặp
While <expression>
statements
WEnd
Parameters
expression điều kiện lặp
Remarks
b1: kiểm tra expression nếu đúng thì làm bước 2 nếu sai thì thoát khỏi vòng lặp
b2: làm statements rồi quay lại b1
Related
ContinueLoop, Do Until, ExitLoop
Example
$i = 0
While $i <= 10
MsgBox(0, "giá trị của $i là:", $i)
$i = $i + 1
WEnd
Macro Reference - AutoIt Related
Dưới đây là một danh sách các macro có trong AutoIt
Các danh sách đầy đủ các macros tại đây .
Macro
Description
@compiled
trả lại 1 nếu script có khả năng biên dịch thành công, còn lại
trả lại 0