Previous Topic

Next Topic

Book Contents

Book Index

Examples of Case Statements

The following case condition will match if the returned FTP code is either 226 or 231.

case (226, 231) :

The following case conditions will match if the returned FTP code is either 226 or 231, or between 250 and 299 inclusive. So 250 itself will match, as well as 251, 252 etc. up to 299

case (226, 231, 250..299) :

The following case conditions will match if the returned FTP code is in the 300s and the returned string contains the text “email address”.

case (300..399) and contains(lastreply, "email address") :

The following case conditions will match if the returned FTP code is 500 or greater and the returned string contains the specified error message

case (500..999) and contains(lastreply, "user %HostUserId cannot login.") :

If a case contains more than one condition they must be separated by and. The and operator specifies that all the listed conditions must be satisfied. So in the previous example, the FTP code must be between 500 and 599 AND the last reply must also contain the specified string. Both must be true. If either is false, the case will not match.

The not operator reverses the result of a function. We may for example want to make sure that the last response does not contain a certain string. For example:

case (500..599) and not contains(lastreply, "server is busy") :

There is no or operator. The same logic may be applied by using multiple case statements.

The following case condition will match if the send command timed out.

case timeout :

Case any is the catch all case, and if present should be the last case in the enclosing list. If it is followed by other case statements they will never be evaluated.

For example, the following case condition will always match.

case any:

If case statements overlap and two case statements would match the response, then the first one encountered will be executed.

Example:

case (200..299) and contains(lastreply, "please send user account") :

...
case (200..299) :
...

If the case with the contains function appeared after the one without it, it would never get evaluated.

See Also

FireScript Statements

Switch Statements

Case Statements

Continue

Jumps and Labels

Return

Autodetect