Question Florian Hansmann · Jun 4, 2024

For Loop over comma seperated String

Hi Community,

My old code:

for x=1,2,3
.dosomethig(x)

Now i Want to customize the comma separated List get from a ClassMethod as String. -> set customString = „1,3,9“

but

for x=customString
.dosomething(x)

wont work for me.

also

for x=$LFS(customString)
.dosomething(x)

doesnt work for me.

i dont want to change the for Loop With an iterator.

is there a possible way to cast the string into a „comma separated List“ for My for Loop?

best regards,

Florian

Product version: Caché 2018.1

Comments

Dean White · Jun 4, 2024

list =$LISTFROMSTRING(line,",",2)

0
Robert Cemper · Jun 4, 2024
x"for x="_customString_" do something(x)"
0
Matjaz Murko · Jun 4, 2024

F x=1:1:$L(customString,",")  dosomething($P(customString,",",x))

0