问题
I would like to make a condition that look each element of a array and if the current element (string) possess a specific charactere, the condition return true. More details: The condition must be true if: - The first charactere is 1 and the third is in a IdList - The first charactere is 0 and the third is in a other IdList
I've try to do this, but it didn't work:
("1;" in {?dlcNatureProduit}[1 to 2] and {FournirRapportR39.NatureProduitType} in {?dlcNatureProduit}[3 to 4] )
OR
(CStr({FournirRapportR39.IdNatureProduit}) in {?dlcNatureProduit}[3 to 4])
The array look like this: 1;1 0;2 0;3 1;3 1;4 1;5 0;6 ...
Thanks for your help.
回答1:
//create an array; split into tokens on ";"
Stringvar Array foo := Split(1;1 0;2 0;3 1;3 1;4 1;5 0;6, ";");
Numbervar i;
// examine all elements in the array
For i:=0 To Ubound(Foo) Do (
// create second array base on first; split on " "
Stringvar Bar := Split(Foo[i]," ");
// first test
If ToNumber(Bar[1])=1 And ToNumber([2])=[] Then
//whatever
ElseIf ToNumber(Bar[1])=1 And ToNumber([2])=[] Then
// whatever
; // semi-colon might be required; doing this code from memory
)
来源:https://stackoverflow.com/questions/16603896/crystal-report-how-check-if-a-string-is-in-a-entry-on-a-array