[Variables] [If] [Switch] [Reference] [Operators]
Status, Tag, Label (Common settings)
In settings pane, tapping top icon opens settings to set the item’s state.
Set normal state.
Set skipped state, to disable the item.
Set marked state, as preferred destination.
Set last destination of Scene Check. If Scene Check does not match any scenes, the sequence starts from the item.
In Label section, tag color and name of the item can be set.
Set tag color. Default color is transparent, at the top-left in tag color palette.
Edit label.
Variables
Substitute / calculate values of Number, String, Rectangle, for the variables of FRep2 app. The designated lines will be executed in order from the top.
Post Process
On Success:
After tapping the button, select from Next, Abort, Return, Item, or tap the destination item directly in the item list of left pane.
Variable
Set the statement(s) to execute; (Variable)=(Code):(Arg1) or (Variable)=(Code):(Arg1)(Operator)(Arg2)
See Reference, Operator for Variables for definitions.
Tapping will append the new statement. Tapping the line item will start edit, at the left will discard the statement, at the right will prepend new statement. To move position, long-tap and drag the line. To copy the line, long-tap .
If
Branch the sequence by condition(s) of variables. If they meets the condition(s), the sequence proceeds to On Success, and @lastif will be 1. If not, the sequence proceeds to On Fail(else), and @lastif will be 0.
Destination
On Success, On Fail(else):
After tapping the button, select from Next, Abort, Return, Item, or tap the destination item directly in the item list of left pane.
Conditions
Set the condition(s) to judge; and/or(not):(Arg1) (Operator) (Arg2)
Logical Operators: And If, Or If, And If Not, Or If Not
To prepare complex conditions, there are 4 type logical operators.
- And If (and:) Previous condition must be met to succeed.
- Or If (or:) New condition check starts even if the above conditions fail.
- And If Not (andnot:) Variant of And If; the condition use the reversed result.
- Or If Not (ornot:) Variant of Or If; the condition use the reversed result.
The first condition ignores its logical operators because they make sense only with previous condition(s). Neither of and: or: cannot be nested. If there are multiple conditions divided by or:, each section is colored in the list.
andnot: ornot: are variant of and: or:, they use the reversed result of each condition check.
See Reference, Operators for If / Switch for for definitions.
Tapping will append the new statement. Tapping the statement will start edit, at the left will discard the statement, at the right will prepend new statement. To move position, long-tap and drag the statement.
Switch
Branch the sequence by condition of variables. Each condition has respective destination. The conditions are evaluated from the top of the list, and the sequence proceeds to the destination of first met condition. When all conditions do not match, it goes to Default: destination.
The available operators are same with If statements, except for combination (and: or: etc).
Cases
List of the statement of condition and its destination.
Tapping will append the new statement. Tapping the statement or destination will start edit, at the left will discard the statement, at the right will prepend new statement. To move position, long-tap and drag the statement.
Other Case
Default:
After tapping the button, select from Next, Abort, Return, Item, or tap the destination item directly in the item list of left pane.
Reference
The values of the variables are common in all sequences, i.e. all variables can be referred / overwritten by other sequences. The values of the variables will be cleared when FRep2 service stops. The values of the referred / written variables are saved to log of the replayed record, which can be browsed from View Last Log (requires FRep2 Unlock Key).
Variable name [A-Za-z_@][0-9A-Za-z_]+
Variable name must consist of alphanumerical characters and under bar(_). First letter cannot be a number. The reserved variables as environmental variables start with @, and they are used only for arguments and some referred values.
Value Type [(Empty), Number, Rectangle, String]
There are 4 value types including empty (null) value. The type of variables are determined by the value they have.
Type | Description | Example |
---|---|---|
(Empty) | The state of no value defined. *Shown as null in Log. | var=num: var=rect: var=str: |
Number | Integer or decimal, including negative value. | var=num:0 var=num:0.012 var=num:-0.5 |
Rectangle | Rectangle defined by: (left top right bottom) Each component must be integer or variable. | var=rect:(10 20 30 40) |
String | String defined by: “character sequence” Escaped characters; (line feed:)\n (tab:)\t (\backslash:)\ (“quote:)\” | var=str:”line1\nline2″ |
@reserved environmental variables
System variables for referring the state of device or playing sequence.
Name | Type | Description |
---|---|---|
@repeat | Number | Current repeat number (0 for first time) |
@loop | Number | Last loop count number (0 for first time) |
@lastif | Number | Last IF result (success/true:1, fail/false:0) |
@rotation | Number | Current orientation of the device (0: 0°, 1:90°, 2:180°, 3:270°) |
@start | Number | Starting time (ms) |
@now | Number | Current time (ms) |
@lastfinish | Number | Success of failure of last replay (0:not replayed, -1:failed/interrupted, 1:successful) |
@laststep | Number | Step No. in Edit Sequence on last replay finish (0 if it is not replayed) |
@lastmatch | Rectangle | Latest successful Image Match position |
@screen | Rectangle | Screen size of the device (for orientation 0°) |
@clipboard | String | Contents of the clipboard text (for reference) *To set clipboard, use Set Clipboard control. (If app change occurs on Android 10~, refer the Clipboard access in System Settings.) |
@labelmatch | String | Latest successful Image Match’s control sequence No. and label. |
@lastocr | String | Latest recognized string by OCR control. *Includes string which numeric conversion failed. |
@labelocr | String | Latest string-recognized OCR’s control sequence No. and label. *Includes failed case only numeric conversion failed. |
@lastsw | String | Last satisfied statement of Switch, or “default” if not satisfied. |
@tofrep | String | Text passed by the caller, by FRep2 Tasker Plugin (Empty when started manually or with shortcut) |
Special modification for variables; var.left, var.x, var.length
For some types of variables, the derived values can be referred by special postfix modification.
Modification | Description | Example |
---|---|---|
(Rect).left (Rect).top (Rect).right (Rect).bottom | Refer each component of the rectangle | l=num:r.left |
(Rect).x (Rect).y | Refer the center x or y of the rectangle x=(left+right)/2 y=(top+bottom)/2 | centerx=num:r.x |
(Rect).width (Rect).height | Refer the width or height of the rectangle width=right-left height=bottom-top | w=num:r.width |
(String).length | Refer the length of the string | len=num:s.length |
(String).asnum (String).asrect | Refer the number from numeric string Refer the rectangle from “(left top right bottom)” type string | n=num:s.asnum r=rect:s.asrect |
(String).asint (Num).asint | Refer the integer number (truncated after the decimal point) | i=num:s.asint j=num:n.asint |
(Num).asstr (Rect).asstr | Refer the number / rectangle as string | s=str:n.asstr s=str:r.asstr |
(Num).asdate (Num).astime | Refer the time (ms) number as date string with format “yyyy/MM/dd kk:mm:ss” Refer the time (ms) number as time difference string with format “hour:min:sec.ms” | s=str:@now.asdate t=num:@now–@start s=str:t.astime |
Operators for Variables
num: Set / Calculate Number
Operator | Arg1 | Arg2 | Description | Example |
---|---|---|---|---|
(None) | Variable, Number | (None) | Set number value | var=num:0 |
+ – * | Variable, Number | Variable, Number | Add Subtract Multiply | var=num:var + 1 |
/ | Variable, Number | Variable, Number | Divide (If Arg2 is 0, result is Arg1) | var=num:var / 3 |
% | Variable, Number | Variable, Number | Residue (If Arg2 is 0, returns 0) | var=num:var % 3 |
& | ^ | Variable, Number | Variable, Number | Bit operation AND OR XOR (Args are forced to be integer) | var=num:var & 7 |
~ | Variable, Number | Variable, Number | Bit operation ANDNOT (Args are forced to be integer) | var=num:var ~ 128 |
rect: Set / Calculate Rectangle
Operator | Arg1 | Arg2 | Description | Example |
---|---|---|---|---|
(None) | Variable, Rectangle | (None) | Set rectangle value | var=rect:(0 0 100 200) |
+ – * | Variable, Rectangle | Variable, Number, Rectangle | Add Subtract Multiply *If Arg2 is rectangle, each component will be used for calculation. If Arg2 is number, it is applied for all components. | var=rect:var + (10 20 10 20) *Move the var rectangle by (10,20) |
/ | Variable, Rectangle | Variable, Number, Rectangle | Divide *If Arg2 is rectangle, each component will be used for calculation. If Arg2 is number, it is applied for all components. When the component is divided by 0, it will not change. | var=rect:var / (2 2 0 0) *Halve the (left, top) coordinates |
& | Variable, Rectangle | Variable, Rectangle | Intersect Retrieve common area in both rectangles. | var=rect:var & @screen *Clip by screen size |
| | Variable, Rectangle | Variable, Rectangle | Union Retrieve the minimum area which covers both rectangles. | var=rect:var | @lastmatch *Expand rectangle to contain image matched area |
str: Set / Calculate String
Operator | Arg1 | Arg2 | Description | Example |
---|---|---|---|---|
(None) | Variable, Number, Rectangle, String | (None) | Set String value | var=str:”char seq” |
+ | Variable, Number, Rectangle, String | Variable, Number, Rectangle | Concatenate 2 values as string | var=str:var + “\n” *Append line feed |
sub | Variable, String | Rectangle | Extract string from Arg1, as defined range of Arg2 (la ln ca cn). When ln>0, extract ln lines from offset:la. When cn>0, extract cn characters from offset:ca. *If la<0 or ca<0, each extraction starts from back position from tail. | var=str:var sub (1 2 5 10) *Extract 2 lines from var, offset:1 (#2,3 line) and then get 10 characters from 6th. var=str:var sub (a 1 0 0) *Extract line #(a+1) from var. var=str:var sub (0 0 -5 5) *Extract last 5 characters from var. |
idx | Variable, String | Variable, String | If Arg1 contains Arg2 string, the position of Arg2 start in Arg1 string (first is 0). If Arg1 does not contain Arg2 string, -1. | var=str:”abcde” idx “cd” *var is set to 2 (num). var=str:”abcde” idx “f” *var is set to -1 (num). |
replace | Variable, String | Variable, String | Converts all strings contained in the destination variable that match Arg1 to Arg2 (Regular Expression) | var=str:”12:34;” var=str:”[;:]” replace “” *var is set to “1234” |
read | Variable, String | (None) | Read the file designated by the path of Arg1. (up to 1MB) *The file path must be an accessible for FRep2 app | var=str:”/sdcard/test.txt” read |
Functional Codes
Code | Arg1 | Arg2 | Description | Example |
---|---|---|---|---|
toast: | Variable, Number, Rectangle, String | (None) | Show the message by popup. | toast:”message” |
clean: | (None) | (None) | Clear all variables except environmental ones(@~). | clean: |
Operators of If / Switch
Operator | Arg1,2 | Description |
---|---|---|
== != | Variable, Number, Rectangle, String | Check if the contents of Args are equal or not equal. |
ex.) | and:var == “char seq” and:@loop == 0 and:var == | Success when var is “char seq” Success during first loop (after start, before end). Success when var is null (undefined). |
> >= < <= | Variable, Number | Compare the numeric values. |
ex.) | and:var > 0 | Success when var is greater than 0. |
& | Variable, Number, Rectangle | If Args are numbers, success on the result of BITAND operation is not zero. If Args are rectangle, success on any intersect area exists. |
ex.) | and:var & 5 and:r & @lastmatch | Success when var BITAND 5 != 0. Check if the result of Image Match hits on r or not. |
]= | Variable, Rectangle, String | If Args are rectangle, success when Arg1 equals or includes whole Arg2 area. If Args are string, success when Arg1 contains Arg2 string. |
ex.) | and:r ]= @lastmatch and:var ]= “ok” | Success when the result of Image Match is in r. Check if var has string “ok” or not. |