Reputation: 49
i was coding with netlogo 3.1.5 and i wrote the next code and it works (the S was already declared in globals [])
set S ""
ifelse (color = green)
[set S S + "0"][set S S + "1"]
the problem is when i wanted to work in netlogo 6.1.1 i copied and past the same code and it shows me an error which is the following: +expected this input to be a number, but got a string instead
so can you please tell me how to set a string and add other strings in it ?
Upvotes: 0
Views: 379
Reputation: 17678
I wasn't using NetLogo back at v3 but I'm assuming the + is to concatenate. If so, the primitive you want is word
. Here's a complete model for demonstration. Note that you need the bracket version if there are more than two inputs.
to testme
let S "A"
print S
set S word S "B"
print S
set S (word S 1 2)
print S
end
Upvotes: 3