foreach(items:local:lines,expresion: local!searchsection: if( or(lower(left(trim(fv!item),7 ) ) = "section", regexmatch("\d{1,2}[.]\d{1,2}", left(trim(fv!item),5 ) )) , "Section: "& cleanwith(left(trim(fv!item),12 ), "1234567890.") ,{}) , local!section:a!refreshVariable( value: local!searchsection ,refreshOnReferencedVarChange: if( rule!NPA_isEmpty(local!searchsection), false(), true() ) ), local!section )
I'm trying to modify the second variable just if the first variable that i have is not null but if it is null i need to keep the last value the variable had
Discussion posts and replies are publicly visible
let me explain a little bit better i'm looping into some lines each of those lines are inside a section but a section could start in any line and i want to know which line is part of which section when i find a section number i want to be able to keep it until we get to capture the next section number.
Hi felixr
If you are trying to get the Section numbers per line, this is something you can try.
I assumed how your data would look like.
Let me know if the data looks different and we could come up with something to help you. Thanks
a!localVariables( /*My assumption of your data*/ local!data: " Hello Section: 1.2 Welcome to Appian Lets start Section: 2.3 Contents Expression Rules Section: 2.8 Process Models", /*Split data by new line character to get line*/ local!lines: split(a!defaultValue(local!data, {}), char(10)), /*Get the line numbers which has the word Section in it*/ local!sectionLineIndexes: where(find("Section:", local!lines)), /*Retrieve section names*/ local!sectionNames: a!forEach( items: local!sectionLineIndexes, expression: cleanwith( left(trim(index(local!lines, fv!item)), 12), "1234567890." ) ), /*Transform sectionLineIndexes array to return an array of number of lines which points to index of its section's name */ local!index: a!flatten( a!forEach( items: local!sectionLineIndexes, expression: { if( fv!isFirst, repeat(fv!item - 1, 0), repeat( fv!item - index(local!sectionLineIndexes, fv!index - 1, 0), fv!index - 1 ) ), if( fv!isLast, repeat( count(local!lines) - fv!item + 1, fv!itemCount ), {} ) } ) ), /*Section Names per line - defaults NA, until Section word is found*/ local!sectionPerLine: a!forEach( items: local!index, expression: if( fv!item = 0, "NA", index(local!sectionNames, fv!item, "") ) ), /*Output - for display purposes*/ a!forEach( items: local!lines, expression: concat( "Line ", text(fv!index, "00"), " | Section ", a!defaultValue( index(local!sectionPerLine, fv!index, ""), "NA" ), ": ", fv!item ) ) )
Hope it helps !
Thanks agam this worked perfectly thanks a lot.