Game Development Community

TGB 1.7.3 passed variables are empty

by James Ford · in Torque Game Builder · 08/24/2008 (10:54 pm) · 2 replies

function createSquad( %factionid )
{
   // THIS LINE IS REQUIRED, OR %factionid WILL ALWAYS BE ""
   //%factionid = %factionid;
   
   %iresult = sqlite.queryb( "INSERT INTO squads(factionid) VALUES ('%factionid')" );
   if ( %iresult == -1 )
      return -1;
      
   return sqlite.lastInsertRowId();   
}

With the top line commented out, %factionid's real value will NOT get passed into this function. This breaks things because I actually use it in the console method "queryb".

If the commented out line at the top is un-commented, miraculously %factionid WILL get passed in with its real value.

To see more tests people have done concerning this bug, look at This Thread.

I have already run into 3 cases where something wasn't working and it turned out to be this bug, requiring me to add a line like %factionid = %factionid to the top of the function.

#1
08/24/2008 (11:50 pm)
How are you calling the createSquad function? How in that instance is the %factionid variable determined?

Is it as simple as:

%factionid = 2;
%row = createSquad(%factionid);
#2
08/25/2008 (1:07 am)
%squad = createSquad($myfaction);

Where $myfaction is set elsewhere entirely. But I can assure you if i echo $myfaction immediately before calling the fuction it is not "".

Since this code I posted is using the sqlite resource + custom modifications its not going to be a good choice as far as trying to reproduce it. A simple case might be.

function testBug1( %var )
{
   testbug2( "%var" );
}

Where testbug2 is a consolefunction defined in C++ that does, Con::getLocalVariable(argv[1]);