Page 1 of 1

[solved] Can't mix strings with numerical values

Posted: Tue May 31, 2016 1:34 pm
by falsam
Hello there ^^

I have a problem with this code.

Code: Select all

;-New message from an user
  !socket.on('usermessage', function(v_data) {
  !   v_username = v_data.username;
  !   v_usermessage = v_data.message;
  AddGadgetItem(#userHistoric, 0,  username + Chr(10) + usermessage)
  !});
AddGadgetItem generates an error message
Can't mix strings with numerical values.
If I replace

Code: Select all

AddGadgetItem(#userHistoric, 0,  username + Chr(10) + usermessage)
with

Code: Select all

AddGadgetItem(#userHistoric, 0,  "" + username + Chr(10) + usermessage)
I do not have this error message.

Thanks for your help.

Re: Can't mix strings with numerical values

Posted: Tue May 31, 2016 1:56 pm
by Fred
You need to declare username with a string type before using it in inline JS. When not using Str(), the string expression needs to start with a string value, not a numeric one.

Re: Can't mix strings with numerical values

Posted: Tue May 31, 2016 2:11 pm
by Peter
Hello falsam,

what about this one?

Code: Select all

;-New message from an user
  Define username.s
  Define usermessage.s
  !socket.on('usermessage', function(v_data) {
  !   v_username = v_data.username;
  !   v_usermessage = v_data.message;
  AddGadgetItem(#userHistoric, 0,  username + Chr(10) + usermessage)
  !});
Greetings ... Peter

Re: Can't mix strings with numerical values

Posted: Tue May 31, 2016 2:37 pm
by falsam
Thanks Fred & Peter. Problem solved.