Commands & Syntax > Commands > Macro Flow Control >

www.perfectkeyboard.com

 

IF FILE - < if_file >() ... [Pro]

 

IF FILE
<if_file>("File","Condition","Parameter")
Available in: Professional edition

The command evaluates a file specific condition and if it is evaluated as "true" then following macro steps (steps between "if" and "else/endif") are executed.

 

#

Parameter name

Parameter description

1

File

Full path to the file to check against the condition.

2

Condition

Condition can be one from the following:
"EXIST" - the condition is true if the file exist.
"NOTEXIST" - the condition is true if the file does not exist.
"BIGGER" - the condition is true if the file size is bigger than the specified size.
"SMALLER" - the condition is true if the file size is smaller than the specified size.
"CONTAIN_NOCASE" - the condition is true if the file contains the text specified in the additional parameter. The text is compared "case insensitive".
"CONTAIN_CASE" - the condition is true if the file contains the text specified in the additional parameter. The text is compared "case sensitive".
"NOT_CONTAIN_NOCASE" - the condition is true if the file does not contain the text specified in the additional parameter. The text is compared "case insensitive".
"NOT_CONTAIN_CASE" - the condition is true if the file does not contain the text specified in the additional parameter. The text is compared "case sensitive".

3

Parameter

Additional parameter:
File size in bytes for BIGGER and SMALLER conditions.
Text to find in the file for CONTAINS and NOT_CONTAINS conditions.

 

Example (Macro Steps):

 

1

<#> <#> This macro shows how to use if-file command

2

Macro execution: ONLY COMMANDS

3

IF FILE "somefile.txt" Exist (0)

4

Message SHOW "Information" : "Somefile.txt surprisingly exist!" (other parameters: x = 100, y = 100, Window title = Message, Buttons = OK, Timeout (seconds) = 0, Always on top = No).

5

ELSE activate

6

Message SHOW "Information" : "Somefile.txt file does not exist." (other parameters: x = 100, y = 100, Window title = Message, Buttons = OK, Timeout (seconds) = 0, Always on top = No).

7

ENDIF

Example (Plain Text):

 

<#> This macro shows how to use if-file command

<cmds>

<if_file>("somefile.txt","EXIST","0")

   <msg>(100,100,"Somefile.txt surprisingly exist!","Message",1,0,0,0)

<else>

   <msg>(100,100,"Somefile.txt file does not exist.","Message",1,0,0,0)

<endif>