LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  Loop through a Text String

    Employee
    Posted 11-17-2016 13:38

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: jpstory

    Hi

    I have a field contains any possible combinations of 4 values ("A","B","C","D")
    What I need to do is make sure the popualted value is one / a combination of the four values above.

    I can do a member test if it's just one value with list.find() but I got stuck when I need to check each one of values populated in this field.

    is there a way to do something like this:


    MyList = list("A","B","C","D")
    i = 0
    while i <=TestField.len()
    Txt = TestField.getItem(i).Str()
    if MyList.find('Txt') == -1 then
    Result = "Fail"
    else
    i = i + 1
    emit TestField, Result


  • 2.  RE: Loop through a Text String

    Employee
    Posted 11-17-2016 13:55

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: gmullin

    You could use the following to scan through the list and compare it for an exact match against the input field. If it was possible that it could be a combination, you could change the == in the if statement to use strFind command to just check that a certain value was present in the input field.

    node:Filter
    bretype:core::Filter
    editor:sortkey=582e1689653363d1
    input:@40fd2c74167f1ca2/=Static_Data.40fe6c55598828e5
    output:@40fd2c7420761db6/=
    prop:Script=<<EOX
    MyList = list("A","B","C","D")
    i = 0
    result = false
    
    while i < MyList.len() and result == false {
    	if MyList[i] == 'TestField' then
    		result = true
    	i = i + 1
    }
    
    emit TestField, result as Result
    EOX
    editor:XY=250,120
    end:Filter
    
    node:Static_Data
    bretype:core::Static Data
    editor:sortkey=582e171c2b885963
    output:@40fe6c55598828e5/=
    prop:StaticData=<<EOX
    TestField
    A
    B
    X
    Z
    B
    D
    EOX
    editor:XY=120,120
    end:Static_Data


  • 3.  RE: Loop through a Text String

    Employee
    Posted 11-17-2016 14:19

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: AdamParker

    Gerard's example is great. But if you want to loop through the string, you can use substr() and increment the offset parameter like so:

    node:Static_Data
    bretype:core::Static Data
    editor:sortkey=582e15cd2ba07e46
    output:@40fe6c55598828e5/=
    prop:StaticData=<<EOX
    TestField:string
    ABCD
    ABD
    BBBD
    BBAC
    BAD
    CDAE
    CDD
    DAA
    DAB
    DDA
    DAAG
    DBD
    DBC
    EOX
    editor:XY=340,310
    end:Static_Data
    
    node:Loop_Through_String
    bretype:core::Filter
    editor:Label=Loop Through String
    editor:sortkey=582e15e55b221eaa
    input:@40fd2c74167f1ca2/=Static_Data.40fe6c55598828e5
    output:@40fd2c7420761db6/=
    prop:Script=<<EOX
    output 1
    {
    	emit 'TestField'
    	emit null.str() as "_txt"
    	emit null.bool() as "_result"
    	where false
    }
    
    _myList = list("A","B","C","D")
    _testField = 'TestField'.str()
    _result = false
    
    i = 0
    while i < _testField.strlen()
    {
    	_txt = _testField.substr(i,1).str()
    	
    	if _myList.find(_txt) > -1
    	then { _result = true }
    	else { _result = false }
    	
    	do output 1
    	{
    		emit _txt
    		emit _result
    	}
    
    	i = i + 1
    }
    
    EOX
    editor:XY=470,310
    end:Loop_Through_String
    
    node:Call_Out_Failures
    bretype:core::Agg Ex
    editor:Label=Call Out Failures
    editor:sortkey=582e1bfb60ea63de
    input:@4b4668c040aa5a85/=Loop_Through_String.40fd2c7420761db6
    output:@4b4668e708143fb4/=
    prop:GroupBy=<<EOX
    'TestField'
    EOX
    prop:Script=<<EOX
    _result = not('_result')
    
    _failed = groupSum(_result.int())
    
    emit referencedFields(1,{{^GroupBy^}})
    where lastInGroup and _failed > 0
    
    EOX
    prop:SortInput=true
    editor:XY=580,310
    node:Bypass
    bretype:::Bypass
    editor:shadow=4b467f7e02db3a85
    input:@4b467f7e129d45c1/=
    input:@4b467f830ffe047b/=
    output:@40fd2c7436717256/=
    end:Bypass
    
    node:Sort
    bretype:::Sort
    editor:shadow=4b467f8972dc33df
    input:@40fd2c743ebf4304/=
    output:@40fd2c746a2a3b47/=
    end:Sort
    
    node:Agg
    bretype:::Agg
    editor:shadow=4b467f9b3d5028c0
    input:@40fd2c7427456e5b/=
    output:@40fd2c744c862db0/=
    end:Agg
    
    end:Call_Out_Failures


  • 4.  RE: Loop through a Text String

    Employee
    Posted 11-18-2016 08:05

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: jpstory

    Worked perfectly, thanks for the responses!