Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

@IF (format 3) - Query @ON hits or work file status

&pagelevel(3)&pagelevel

This format of the @IF statement makes it possible to check in EDT procedures whether EDT identified a hit the last time @ON was executed or whether the current work file is empty. Depending on the result, a specified string either is or is not processed as input.

Operation

Operands

L mode

@IF

{ .TRUE. [rel col] |  .FALSE. |  .EMPTY. }:[text]

.TRUE.

Processing branches if a hit was identified in the current work file the last
time @ON was executed.

If rel and col are specified then the condition is structured in such a way
that the column number in which the first identified hit begins is compared
with the column number specified by col using the relational operator
indicated by rel. The condition is only considered to be fulfilled if this
comparison is positive.

rel

Defines the relational operator for the column numbers (see above):

Symbol

Meaning

>      or       GT

greater than

<      or       LT

less than

>=     or       GE

greater than or equal to

<=     or       LE

less than or equal to

=      or       EQ

equal to

<>     or       NE

not equal to

col

Column number which is compared with the number of the column in which
the first hit started in the current work file when the last @ON statement was
executed.

.FALSE.

Processing branches if no hit was identified in the current work file the last
time @ON was executed.

.EMPTY.

Processing branches if the current work file is empty. A work file is empty if
it contains no records

text

EDT statement or data line. If the condition is fulfilled, the string is treated
as if it had been entered at the prompt in L mode. In particular, the decision
to interpret the text as data input or as a statement is made in accordance
with the same rules (for more information, see section “L mode”).

The text operand starts immediately after the character ':', i.e. any
specified blanks form part of the operand and are taken over into the line in
the case of data input.

If text is not specified (although the colon is), then an empty line (line of
length 0) is inserted.

The previous specification of GOTO or RETURN without a colon continues to be supported for reasons of compatibility.

Note

Using @IF with @RETURN as a statement outside of procedures may cause EDT to terminate (see the @RETURN statement).

Example 1

5.     @PRINT
1.0000 WHO
2.0000 WANTS
3.0000 TO TRY
4.0000 HIS LUCK
5.     @PROC 8
1.     @ @ON ! FIND 'I'
2.     @ @IF .FALSE. : @GOTO 4 --------------------------------------- (1)
3.     @ @CREATE !: '*' * 20
4.     @ @CONTINUE
5.     @END
5.     @DO 8,!=%,$ --------------------------------------------------- (2)
5.     @PRINT
1.0000 WHO
2.0000 WANTS
3.0000 TO TRY
4.0000 ********************
5.
(1)

In work file 8, the line numbers are addressed via the loop counter !. If the letter I is not present in one of the addressed lines then the line remains unchanged. Otherwise, the line content is to be replaced by 20 asterisks.

(2)

Work file 8 is executed. During processing, all the lines in the main file are to be addressed in sequence by the loop counter !.


Example 2

5.     @PRINT
1.0000 WHO
2.0000 WANTS
3.0000 PLENTY OF
4.0000 LUCK?
5.     @PROC 9
1.     @ @ON ! FIND 'EN'
2.     @ @IF .TRUE. = 3 : @GOTO 4
3.     @ @GOTO 5 ----------------------------------------------------- (1)
4.     @ @SUFFIX ! WITH ' GOOD'
5.     @ @CONTINUE
6.     @END
5.     @DO 9,!=%,$ --------------------------------------------------- (2)
5.     @PRINT
1.0000 WHO
2.0000 WANTS
3.0000 PLENTY OF GOOD
4.0000 LUCK?
5.
(1)

In the procedure in work file 9, the line numbers are addressed via the loop counter !.

If the string EN occurs in columns 3 to 4 of one of the lines addressed in this way, then the string GOOD is to be appended to it. Otherwise, the line is left unchanged.

(2)

The procedure in work file 9 is executed. During processing, all the lines in the main file are addressed in sequence by the loop counter !.