Crystal Report - How check if a string is in a entry on a array?

本秂侑毒 提交于 2019-12-11 11:38:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!