ACR Electronics FPR-10 PROGRAMMER Manuel Page 52

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 199
  • Table des matières
  • DEPANNAGE
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 51
Parker Hannifin
52 Programmer’s Guide
When using an IF/THEN statement, observe the following:
You can nest GOTO and GOSUB statements in an IF/THEN
statement.
Example
The following demonstrates several simple IF/THEN statements.
IF (BIT 24) THEN P0 = P0+1
IF (P0 > 4000) THEN GOSUB 100 : P0 = P0-1
IF/ELSE
The IF/ELSE statement provides a powerful tool for program
branching and program flow control. The IF/ELSE statement allows
you to run one set of code if the condition is true, and another set of
code if the condition is false. The IF/ELSE statement must end with
ENDIF.
When using an IF/ELSE statement, observe the following:
You can nest GOSUB statements in an IF/ELSE statement. The
GOSUB provides a return into the IF/ELSE statement.
Do not nest GOTO statements in IF/ELSE statements. The GOTO
statement exits the IF/ELSE statements, and does not provide
any link back inside.
Do not nest IF/THEN statements in IF/ELSE statements—the logic
may not provide the results you expect.
Tip: When troubleshooting programs, use the LIST command to
view the program stored on the controller. In recognizing
IF/ELSE statements, the controller indents the statements
under the IF including the ENDIF. If any statements in the
IF/ELSE are not indented but should be, check the code in
the program editor and re-download.
Example
The following demonstrates different actions based on conditions
being true or false. If the input (bit 24) is true, the long array
increments and axis X moves an incremental 25 units. If false, the
long array decrements and axis Y moves to absolute position 5.
IF (BIT 24)
LA0(1) = LA0(1)+1
X/25
ELSE
LA0(1) = LA0(1)-1
Y5
ENDIF
ELSEIF Condition
The IF/ELSE statement can include the ELSEIF condition. The ELSEIF
condition lets you create a series of circumstances to test. There is
no practical limit to the number of ELSEIF conditions you can
include. However, they must come before the ELSE condition.
Vue de la page 51
1 2 ... 47 48 49 50 51 52 53 54 55 56 57 ... 198 199

Commentaires sur ces manuels

Pas de commentaire