Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hak5
GitHub Repository: hak5/usbrubberducky-payloads
Path: blob/master/payloads/examples/Conditions/Conditions-example5.txt
2968 views
1
REM The syntax of IF states that in nearly all cases the expression should be surrounded by parenthesis ( ) — however there is an exception to this rule.
2
REM If the condition of only one variable is true or false, the parenthesis may be omitted. This results in a slightly smaller encoded inject.bin file as well as slightly faster payload execution. This is because it removes the step of first reducing the order precedence.
3
4
REM Example of optimized and unoptimized IF statements
5
REM Consider
6
VAR $FLAG = TRUE
7
8
IF $FLAG THEN
9
STRING FLAG is TRUE
10
END_IF
11
12
REM versus
13
14
IF ( $FLAG == TRUE ) THEN
15
STRING FLAG is TRUE
16
END_IF
17
18
19
REM In the first example, the IF statement without the parenthesis results in a 6 bytes added to the compiled inject.bin file.
20
REM In the second example, the IF statement surrounded by parenthesis results in 16 bytes added to the compiled inject.bin file.
21
22