# IF¶

## Function¶

IF selectively executes program statements dependent on result of an expression.

## Syntax¶

IF A(op)B THEN C

Where A is an expression, variable or constant and (op) is an operator =, < , > etc. The operator may be logical or omitted. See section Logical Operators for further details.

B is an expression, variable or constant

C is either a line number or program statement.

## Examples¶

```IF A = B THEN 100
IF A>B THEN PRINT "NO"
```

C may be a multiple statement which will be entirely executed if the condition is true, but skipped if not.

HUNTER also permits nesting of IF statements.

Example:

```IF A= B THEN IF C=D THEN PRINT "FINISHED":GOTO 1000
```

String expressions may be tested for equality or unequality, for example:

```IF A\$ + B\$ = "ABCDEAB" THEN 100
```

or

```IF A=B AND B=C OR D=5 THEN PRINT "TRUE"
```

In this example “TRUE” may be printed by one of two methods allowed by the OR operator as follows:

1. if A=B=C

2. if D=5

However,

```IF A=B AND B=C AND D=5 THEN PRINT "TRUE"
```

will only print “TRUE” if all conditions are satisfied.

```IF A THEN PRINT "TRUE"
```

will print “TRUE” only if the variable A is non-zero, i.e. if A=-19 then “TRUE” will be printed.

See Expressions And Operators and Logical Operators, for precise details of logical operators.

## Remarks¶

For strings of unequal length the equality will be true if the string on the left of the equates is equal to or part of the string on the right as follows:

If A\$ = “ABC” and B\$ = “ABCD” then

• A\$ = B\$ is true

• B\$ = A\$ is not true
{"ft_lang_label":"__label__en","ft_lang_prob":0.8182216,"math_prob":0.9899687,"size":1471,"snap":"2023-40-2023-50","text_gpt3_token_len":389,"char_repetition_ratio":0.116564415,"word_repetition_ratio":0.014705882,"special_character_ratio":0.25628823,"punctuation_ratio":0.084415585,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9994248,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-11-28T15:38:14Z\",\"WARC-Record-ID\":\"<urn:uuid:0e5e3b0c-193a-4e0b-88d5-d18527ff9210>\",\"Content-Length\":\"21911\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:2f853aeb-23d0-4bad-af22-200765793d8c>\",\"WARC-Concurrent-To\":\"<urn:uuid:77cbdf30-3b78-4e8f-8a94-52a667e49b26>\",\"WARC-IP-Address\":\"103.168.172.37\",\"WARC-Target-URI\":\"https://hunter2.staddle.net/operations-manual/basic-functions/if.html\",\"WARC-Payload-Digest\":\"sha1:GAGIJAH6F3NQTFIP7WIBLRDHZWJX3OQD\",\"WARC-Block-Digest\":\"sha1:DWT7LWDFA64XJ3S6IIVA3F5WEN37Z2A3\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-50/CC-MAIN-2023-50_segments_1700679099892.46_warc_CC-MAIN-20231128151412-20231128181412-00674.warc.gz\"}"}