CAPITAL NETO DE TRABAJO
2. DISCUSIÓN DE LOS RESULTADOS
WHEN/T1
You can also define the text within the WHEN statement: WHEN/(TEXT/’MIST’)
The following is a general example of a CASE statement:
CASE/s1 $$ Set case variable s1
WHEN/I $$ Execute if s1 = 1 statement statement WHEN/i1,i2 $$ Execute if s1 = i1 or i2 statement statement
WHEN/2,THRU,12 $$ Execute if s1 is 2 through I2
statement statement
WHEN/OTHERS $$ Execute if s1 is not 1
statement $$ or i1 or I2 or 2 through 12
statement
ENDCAS $$ End of CASE statement
CASE/t1 $$ Set case variable t1
WHEN/(TEXT/’CLW’) $$ Execute if t1=CLW statement statement WHEN/T2,T3 $$ Execute it t1 = T2 or T3 statement statement
ENDCAS $$ End of CASE statement
4.23.2.7 DO Loop
The DO loop feature provides an automatic mechanism for controlling the repetitive execution of a series of statements. A DO loop has the following format:
DO/label, name=first, limit, incr .
label)
The statements starting with the one following the DO statement and ending with the labeled statement are executed repetitively as specified by the entries in the DO statement, which have the following
significance:
• label is a statement label denoting the final statement of the DO loop. It is required that there be a command on the DO loop statement label. The final statement of a DO loop cannot be a macro call. • name is the symbol for a scalar called the DO variable, which is varied for each repetition of the loop. • first is the value of the DO variable for the first execution of the loop. It may be positive, negative, or
zero.
• limit is the limiting value of the DO variable. It may be positive, negative, or zero.
• incr is the incremental value added to the DO variable for each repetition of the loop. It may be positive or negative but not zero. If omitted, incr is assumed to be 1.
For negative incr, stepping of the DO variable is from the first value down to the limit value. If the limit cannot be reached exactly, the final value is the smallest value that can be reached that is greater than the For example, the following DO statements generate the indicated series of values for the DO variable.
Values of N DO/S1, N=1, 4, 1 (1, 2, 3, 4) DO/S1, N= 1, 4 (1, 2, 3, 4) DO/S1, N= 2, 10, 2 (2, 4, 6, 8, 10) DO/S1, N=1, 10, 2 (1, 3, 5, 7, 9) DO/S1, N=1.5, 4,.5 (1.5, 2, 2.5, 3, 3.5, 4) DO/S1, N=4, 1, -1 (4, 3, 2, 1) DO/S1, N=10, 2, -2 (10, 8, 6, 4, 2) DO/S1, N=9, 2, -2 (9, 7, 5, 3) DO/S1, N=-2, 4, 2 (-2, 0, 2, 4)
If the first value equals or is beyond the limit, the loop is executed once, with the DO variable equal to the first value. The following statements, for example, cause the loop to be executed once with the indicated value for the DO variable:
DO/S1, N=2, 2, 1 (2) DO/S1, N=4, 1, 1 (4) DO/S1, N=1, 4, -1 (1)
In addition to serving as a loop counter, the DO variable can be used like any scalar variable within the loop - - as a subscript or in computing expressions. The DO variable can even be modified within the loop, but this should be done very carefully, if at all, since doing it improperly could cause an endless loop. When all repetitions of a DO loop have been completed, the DO variable will retain the value that it had for the final repetition and may subsequently be used outside the loop like a regular scalar variable.
Example:
DO/S10, N=1, 6 -
S10)
A=N+1 (A=6+1=7)
A DO loop included within another DO loop is called a nested DO loop. As many as 10 levels of DO loops may be in effect at the same time in this manner. If a macro called within a DO loop contains a DO loop itself, this constitutes a nested DO loop.
The following example illustrates one DO loop nested within another: DO/S20, L=1, 4 DO/S1O, N=1, 3 --- S10)--- --- S20)CONTIN
More than one DO loop can end on the same statement, as in the following example: DO/S10, M=1, 3
DO/S10, N=1, 2 ---
S10)CONTIN
It is not permissible for DO loops to overlap as in the following example: DO/S10, M=1, 3
DO/S20, N=1, 2 ---
S10)---
S20)CONTIN
The following example illustrates the use of a nested DO loop to generate a rectangular grid of points. For comparison, the example is also programmed using an FIL loop.
Example: DO/S1, Y=1.5, 7.5, 2 DO/S1, X=2.5, 8.5, 1.5 GOTO/X, Y, 0 GODLTA/0, 0, -1 S1) GODLTA/0, 0, 1 Y = 1.5 S2) GOTO/X, Y, 0 GODLTA/0, 0, -1 GODLTA/0, 0, 1 S1) X=2.5 X=X+1.5 IF(X-8.5)S2, S2, S3 S3) Y=Y+2 IF(Y-7.5)S1, S1, S4 S4) ---
It is permissible to transfer out of a DO loop using an IF or JUMPTO statement. When this occurs, the DO variable retains the value that it had at the time of the transfer.
Example: RESERV/P,50 DO/S1,N=1,50,1 P(N) = POINT/(N*.5),0,0 S1) DO/S2,N=1,50,1
T=CANF(P(N),1) $$ T = X VALUE OF POINT IF(T.GT.10)THEN JUMPTO/S3 ELSE GOTO/P(N) ENDIF S2) CONTIN
4.23.2.8 DO-WHEN Loop
This is a special form of a DO loop. It executes the loop for the specified WHEN values of the DO loop variable. In some cases it may be more convenient to use than the regular DO loop form.
DO/label,name=val1,val2,val3,…,valn,WHEN …
…
label)CONTIN
Example: DO-WHEN loop will process (I1=1, 14, 31, 44, 47). DO/10,I1=1,14,31,44,47,WHEN FEDRAT/I1 GOTO/P1 … … 10)CONTIN
Compare the above DO-WHEN loop with the following regular DO-Loop: DO/10,I1=1,,50
IF(I1 .EQ, 1)JUMPTO/5 IF(I1 .EQ, 14)JUMPTO/5 IF(I1 .EQ, 31)JUMPTO/5 IF(I1 .EQ, 44)JUMPTO/5 IF(I1 .EQ, 47)JUMPTO/5 JUMPTO/10 5)CONTIN FEDRAT/I1 GOTO/P1 10)CONTIN
4.23.2.9 JUMPTO
The JUMPTO statement can be used to program an unconditional jump. Its format is: JUMPTO/label
FIL transfers to the statement with the designated label and executes it next.
For example, suppose that F is a scalar that represents a feed rate. If F is 10 or less, set the spindle speed to 200; if greater than 10, set the speed to 250.
IF( F-10 ) S1, S1, S2 S1) SPINDL/200 JUMPTO/S3 S2) SPINDL/250 S3)
4.23.2.10 EXIT/NOW
The EXIT/NOW command can be used to exit out of a CIMFIL/ON-OFF section. Compare this to use of JUMPTO/cmd to CIMFIL/OFF section with a label. Both can be used however EXIT/NOW is a simpler method. EXIT/NOW is not allowed inside a macro, you must use a JUMPTO/cmd to the statement lablel at or before the TERMAC to exit a macro.
Example: