Game Development Community

parse errors with Con::Evaluate

by Justin Mosiman · in Torque Game Builder · 07/25/2009 (2:06 pm) · 3 replies

Hello,

I'm working on networking in my game, and when a user wants to connect to a server they are given a list of buttons with IP addresses on them to choose from if there is more than one server available. This all goes well and everything, except on that button I want to set the command to pass the IP to a different function. This has lead me to discover a strange error when I try to set the command.

To simply things, the function and button command are set as:
new GuiButtonCtrl(Select) {
         ...
         Command = "echoFunction(192.168.0.1);";
         ...
      };
....
function echoFunction(%echoText)
{
	echo(%echoText);
}

When I push the button, I get this error:
Quote:
parse error
Con::Evaluate(echoFunction(192.168.0.1);) failed

Making things simpler, I set command to "echoFunction(192 168 0 1);" to see if there was a problem with periods. Nope:
Quote:
parse error
Con::Evaluate(echoFunction(192 168 0 1);) failed

Thinking it could be a problem with non-alpha numeric characters, I tried "echoFunction(192a168a0a1);" but it still failed.

What's going on here? Anybody else seen this before?

#1
07/25/2009 (2:29 pm)
Have you tried: "echoFunction(\"192.168.0.1\");";
#2
07/25/2009 (2:36 pm)
I think it's probably seeing the first period and thinking you're passing a float. Obviously a float can't have more than one period, so you have to pass it as a string, as Phillip pointed out.
#3
07/25/2009 (2:40 pm)
Well that was easy, thanks guys.