Game Development Community

%variables without quotation marks?

by Stefan Lundmark · in Torque Game Engine · 10/05/2004 (9:48 am) · 10 replies

When assigning.

%variable = hello;
If you echo %variable, it will give you "hello". WITH the quotation marks.
This won't work with the datablock I'm using, is there any way to get rid of those?

#1
10/05/2004 (10:17 am)
Stefan


Using both this....

function quoteTest()
{
	%variable = hello;
	
	echo(%variable);
}

and this....

function quoteTest()
{
	%variable = "hello";
	
	echo(%variable);
}


Both produce the same result for me. "hello" is echo'ed into the console without the quotes. Are you sure something else isn't getting screwed somewhere?
#2
10/05/2004 (11:04 am)
Sorry Gonzo, I mistyped the whole problem.

echo doesn't show the quotes, but I'll examplify my problem in detail.

function write()
{
%string = test;
echo (%client.character); // This gives test as output, without quotes.
%file = new FileObject();
%file.openforWrite("data/test/test.cs");
%file.writeLine("datablock PlayerData(\"" @%string@ "\")"); //While this gives with the quotes

The above function writes a datablock. Datablocks are not allowed to contain "" in their names. I've attached the following output that was written in the file to show what I mean.

Quote:
datablock PlayerData("test")
{
This won't work. It will give a syntax error back.

Quote:
datablock PlayerData(test)
{
This will work, but I can't get it this way with the variables, at least not with my tests.
#3
10/05/2004 (11:12 am)
Not sure if I understand you correctly, but wont it work like you want if you leave the quote characters(\") out:

Change

%file.writeLine("datablock PlayerData([b]\"[/b]" @%string@ "[b]\"[/b])");

to

%file.writeLine("datablock PlayerData(" @%string@ ")");
#4
10/05/2004 (11:41 am)
My excuses.. I was assuming the syntax wouldn't work if I took away the slashes and the quotes.

So the slashes are merely used as seperators for the two quotes, as I take it.
Thanks for the help.
#5
10/05/2004 (11:46 am)
No problem. I've been confused by them before as well.
#6
10/06/2004 (9:18 am)
The \ is an escape designator... so \" says "escape the " so it can become a printable character.

usually you see it as \n for a new line
#7
10/06/2004 (9:31 am)
Thanks Harold.
#8
03/28/2010 (8:16 pm)
I'm trying to do the same Stefan? Did you ever find a solution to removing quotation marks and \ new line characters? Working with T2D for iPhone I can't just use FileObject to write to a file. I was told I had to use Export. When I export out then load back in I seem to be carrying over " and / and they continually add to the string each time which in turn breaks the sorting of my high scores.

Exporting $Strapped::Score*

When I save out and then load those lines back into the array I get stuff like I'm using StripChars to remove all the other crap so I get in return:

"\"1700"\"" after a couple of exports sorts and loading and just gets worse as I go along.

Any ideas guys?
#9
03/28/2010 (10:08 pm)
Think I might have figured this out. A combination of reading while writing wasn't finished and some more extensive character stripping. If I get this working I will be putting it up as a resource for a basic high score with sorting for the iPhone games using T2D for iPhone. It may end up being butt ugly code but will give some of us newer T2D for iPhone something to start with as a basic way to save info and read it back out in a format that is useful.

#10
03/29/2010 (5:06 am)
did anyone try:
%variable = 'hello';
I think this will make 'hello' a string literal.