2013-05-17 16 views
1

我想創建一個條件,查看數組中的每個元素,並且如果當前元素(字符串)具有特定的字符,則條件返回true。 更多細節: 的條件必須是真實的,如果: - 第charactere是1,第三個是在IDLIST - 第一個charactere爲0,三是在其他IDLISTCrystal Report - 如何檢查字符串是否在數組中的條目中?

我試着做到這一點,但它沒有工作:

("1;" in {?dlcNatureProduit}[1 to 2] and {FournirRapportR39.NatureProduitType} in {?dlcNatureProduit}[3 to 4]) 
OR 
(CStr({FournirRapportR39.IdNatureProduit}) in {?dlcNatureProduit}[3 to 4]) 

陣列看起來像這樣: 1; 1 0; 2 0; 3 1; 3 1; 4 1; 5 0; 6 ...

感謝您的幫助。

回答

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 
) 
+0

感謝您的回答。我做了類似的事情,我把自定義函數放在裏面,它也可以工作。 –

相關問題