VEX "len" function doesn't seem to work

   1453   1   0
User Avatar
Member
87 posts
Joined: Sept. 2019
Offline
I've got an array named Agent that is populated with 40 strings. Any attempt to call len(Agent) gives me the following error:


Warning
Ambiguous call to function len(). Candidates are: int len(matrix2), int len(matrix3), int len(matrix), int len(dict), int len(vector4), int len(string), int len(vector2), int len(vector), int len(matrix2), int len(matrix3), int len(matrix), int len(bsdf), int len(dict), int len(float), int len(int), int len(vector4), int len(string), int len(vector2), int len(vector) (11,5:7)

It does work if I create the array in-line, by simply plugging in {1, 2, 3, 4, 5} for example, but I can't make it reference an already-populated array, and the documentation on this function is remarkably sparse. Am I using the wrong syntax, or is this just not possible?
User Avatar
Member
9380 posts
Joined: July 2007
Offline
gordig
Am I using the wrong syntax, or is this just not possible?
You are most probably just using wrong syntax where the type of a variable may not be clear to len function
Easiest is to first assign your array to a variable and then call len() on that variable
Since using overloaded functions (like point() etc...) inside len() would most likely be ambiguous
but that's just my assumption about what you are doing, it would help to paste your code here
Edited by tamte - April 8, 2023 01:38:05
Tomas Slancik
CG Supervisor
Framestore, NY
  • Quick Links