cancel
Showing results for 
Search instead for 
Did you mean: 

While Wend Loop

Former Member
0 Kudos

Post Author: John

CA Forum: Formula

I have this code in CR 9....

WhilePrintingRecords;stringVar flaga := 'false';stringVar flagb := 'false';numberVar a := 0;

While {Combine_CR_Table.Field1} = {Combine_CR_Table.Field1} do If {Combine_CR_Table.Field7} = "TLC METHOD" and flaga <> 'true' then a := a + 1 * (remaining text does not appear to be part of formula)

flaga := 'true' *(remaining text does not appear to be part of formula)

If {Combine_CR_Table.Field7} = "GC/MS METHOD" and flagb <> 'true' then a := a + 1 flagb := 'true'

Wend *(No matter what I add to the code above, ";" or "and".. this keeps reading that it is not part of the formula.)

a := a + 1

flaga := 'false'flagb := 'false'

So.. the errors I am getting are the same. Note *s above. I have used Else If, End If, and tried ";" and "and" at the end of each line.

If I take from the "Wend" down, out, and put a ; after the addition (a := a + 1) and the first flaga = "true" then I get no errors when I perform a check. However, when I run it, it gives me an error "The loop was evaluated more than the maximum number of times".

Anybody see the holes in this code and why it won't let me put If statements in and While/Wend command?

Thanks

John

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Post Author: John

CA Forum: Formula

AHHHH.. so.. the good old idiot gene came through again for me! Yeah, don't know why I didn't see that about the While loop.

Is there a "Next" command to make it compare the next record?

Thanks

Former Member
0 Kudos

Post Author: SKodidine

CA Forum: Formula

I see two issues. The first one being your While condition. When is this ever NOT true? Field1 will always equal Field1. It is an infinite loop and CR has a loop limit of 100k or so and hence the error.

The second issue is that of syntax.

While {Combine_CR_Table.Field1} = {Combine_CR_Table.Field1} do

( If {Combine_CR_Table.Field7} = "TLC METHOD" and flaga <> 'true' then (a := a + 1;

flaga := 'true');

If {Combine_CR_Table.Field7} = "GC/MS METHOD" and flagb <> 'true' then (a := a + 1 ; flagb := 'true');

);