Abstracting a substring from variables doesn't work

I have a variable with a list with filenames. The length of a filenames is 22 characters. I’m trying to get the names out of the variable one by one into another variable. With every sequence the starting position shifts 22 positions to the end to pick another 22 characters being the name of the next file. In the cli output the variable holds 2 file names and for some reason, I don’t understand and I didn’t find a way to make it work and to fix this, getting a substring out of the variable that holds the list, based on the value of ${POSITION} and ${NAME_LENGTH}, doesn’t work. Am I trying the impossible or do I oversee the obvious? Thanks in advance,

exten => s,n, Set(POSITION=$[${COUNTER2}*${NAME_LENGTH}]) ;
exten => s,n, NoOp(The positon in the variable is : ${POSITION})
exten => s,n, NoOp(The namelength of the files is : ${NAME_LENGTH})
exten => s,n, Set(STORED_MESSAGE_FILE_NAME=${STORED_MESSAGES_LIST}:${POSITION}:${NAME_LENGTH})

This is the cli output:
Executing [s@step2_resending_messages:13] Set(“SIP/5556-0000005b”, “POSITION=0”) in new stack
– Executing [s@step2_resending_messages:14] NoOp(“SIP/5556-0000005b”, “The positon in the variable is : 0”) in new stack
– Executing [s@step2_resending_messages:15] NoOp(“SIP/5556-0000005b”, “The name length of the file is : 22”) in new stack
– Executing [s@step2_resending_messages:16] Set(“SIP/5556-0000005b”, "STORED_MESSAGE_FILE_NAME= 1479552730-5553.queue
– 1479552752-5553.queue
.
.
.
– Executing [s@step2_resending_messages:13] Set(“SIP/5556-0000005b”, “POSITION=22”) in new stack
– Executing [s@step2_resending_messages:14] NoOp(“SIP/5556-0000005b”, “The position in the variable is : 22”) in new stack
– Executing [s@step2_resending_messages:15] NoOp(“SIP/5556-0000005b”, “The namelength of the files is : 22”) in new stack
– Executing [s@step2_resending_messages:16] Set(“SIP/5556-0000005b”, "STORED_MESSAGE_FILE_NAME= 1479552730-5553.queue
– 1479552752-5553.queue

There shouldn’t be a “}” before the “:”.

David551, thanks for the response but can you please show me how it should look like to make it work. When I erase a } I should erase a { somewhere I guess to keep the balance. You really should help me a lot, this kind of drives me nuts. Thanks in advance.
/EdW

I finally got it. Will never forget it.

exten => s,n, Set(STORED_MESSAGE_FILE_NAME=${STORED_MESSAGES_LIST:${POSITION}:${NAME_LENGTH}})

:slight_smile: