List loading in a loop

1,815 views
Skip to first unread message

arvind

unread,
Mar 6, 2012, 9:18:06 PM3/6/12
to robotframework-users
Hello,
I am trying to write a for loop to load strings into a list as follows
${list}= Create List
:FOR ${index} IN RANGE 1 5
\ ${value}= Catenate ${Msg} ${empty}
\ Append to List ${list} ${value}

LOG ${list} warn
#${cnt}= get length ${list}
#LOG ${cnt} warn
#${x}= Get From List ${list} 3
#log ${x} warn

The catenate is in place to avoid the expected keyword error. I seem
to be able to load the list but get this error message "Cannot assign
return values: Expected list-like object, got unicode instead."
When I replace Catenate ${Msg} ${empty} with Evaluate ${index}*2,
no errors

Is it because the Msg variable contains CRLFs, other special
characters?
Any help will be much appreciated

Thanks,Arvind

Ed Manlove

unread,
Mar 7, 2012, 6:30:06 AM3/7/12
to arvi...@gmail.com, robotframework-users

Arvind,

I believe you might be using the wrong notation for list variable type.
Instead of ${my_list} it should be @{my_list}. See the robot framework
User's Guide at


http://robotframework.googlecode.com/hg/doc/userguide/RobotFrameworkUserGuide.html?r=2.6.3#variable-types

Ed

Pekka Klärck

unread,
Mar 10, 2012, 4:58:25 AM3/10/12
to arvi...@gmail.com, robotframework-users
2012/3/7 arvind <arvi...@gmail.com>:

> Hello,
> I am trying to write a for loop to load strings into a list as follows
>        ${list}=        Create List
>        :FOR  ${index}  IN RANGE        1  5
>        \       ${value}=       Catenate   ${Msg} ${empty}
>        \       Append to List  ${list}         ${value}
>
>                LOG     ${list}         warn
>                #${cnt}=        get length      ${list}
>                #LOG    ${cnt}          warn
>                #${x}=  Get From List   ${list} 3
>                #log    ${x}    warn
>
> The catenate is in place to avoid the expected keyword error.

I don't see any reason why you should need Catenate in this example.

> I seem to be able to load the list but get this error message "Cannot assign
> return values: Expected list-like object, got unicode instead."

Where exactly you get this error? I don't see any syntax that should cause it.

> When I replace Catenate   ${Msg} ${empty} with Evaluate  ${index}*2,
> no errors

This is strange. I don't see why that would affect anything.

> Is it because the Msg variable contains CRLFs, other special
> characters?

That definitely shouldn't have anything to do with this. If it does,
then there's a bug in Robot itself.

> Any help will be much appreciated

You could help understanding this problem yourself by creating a
simple stand-alone example that demonstrates the problem.

Cheers,
.peke
--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org

Reply all
Reply to author
Forward
0 new messages