Command line torquescript syntatx checker?
by Clint S. Brewer · in Torque Game Engine · 07/27/2005 (4:44 pm) · 6 replies
Is there some sort command line utility that will do a test compile of a cs / gui file or a syntax checker of some sort?
I'm using textpad and would like to add a custom toolbar button to check the current file.
I'm using textpad and would like to add a custom toolbar button to check the current file.
About the author
Recent Threads
#2
Edit again: fixed function, had some testing caca in there
Almost there:
now just need to turn the filename passed in into the proper sub directory style filename.
aka if you get c:\blah\blah\game\mod\server\scripts\file.cs
turn it into something that compile will understand: mod/server/scripts/file.cs or whatever....
07/27/2005 (5:54 pm)
Edit: thanks for the quick pointer Ben, sounds like a piece of cake..Edit again: fixed function, had some testing caca in there
Almost there:
case "-testCompile":
$argUsed[$i]++;
error("===========================");
error("TEST COMPILE=================\n\n\n\n\n\n");
if ($hasNextArg)
{
$TextCompileFile = $nextArg;
compile($TextCompileFile);
$i++;
}
else
{
error("BAD TESTCOMPILE SYNTAX");
}
error("\n\n\n\n\n\nEND TEST COMPILE=================");
error("===========================");
quit();now just need to turn the filename passed in into the proper sub directory style filename.
aka if you get c:\blah\blah\game\mod\server\scripts\file.cs
turn it into something that compile will understand: mod/server/scripts/file.cs or whatever....
#3
barely tested,
and uncleaned up,
but seems to work great so far...
in your root main.cs, add this option case to the section that parses arguments
To set textpad up, make a new tool in preferences, mine is "test compile torque script"
set it up with the following options:
command: your app, mine is "F:\USR\people\unearthedgames\ProjectLazarus\Prototype\ProjectLazarus\ProjectLazarus_Internal.exe"
parameters: -testCompile $File
initialFolder: your app folder, mine is
"F:\USR\people\unearthedgames\ProjectLazarus\Prototype\ProjectLazarus\"
I dont' have anything else checked.
All done, then just open up the script file you want to compile and choose the tools->"test compile torque script" option.
It will do a quick run of your app compiling the script and the results will be output in console.log
a good compile might look like this:
and a bad compile might look like this:
I tried to compile main.cs itself and it has an error compiling, but that's ok for me since everything else worked fine.
Also of note: for the script paths, the above code uses whatever $userMods is set to for the modpaths when that option is parsed. Something to keep in mind if it's not finding the scripts.
WARNING: the code above assumes the paths are coming in windows format with \'s and not /'s. if you are using /'s the above code will loop infinitely, it'd be easy to fix with a couple sanity checks but it's not there yet.
07/27/2005 (7:05 pm)
All right hear we go, barely tested,
and uncleaned up,
but seems to work great so far...
in your root main.cs, add this option case to the section that parses arguments
case "-testCompile":
$argUsed[$i]++;
error("===========================");
error("TEST COMPILE=================\n\n\n\n\n\n");
if ($hasNextArg)
{
//note that the mod paths must be set in order to find the files
setModPaths($userMods);
$TextCompileFile = $nextArg;
$tmp = $Game::argv[0];
$lastSlashPos = -1;
$nextOffset = 0;
$curPos = strPos($tmp, "\", $nextOffset);
while( $curPos!= -1)
{
$nextOffset = $curPos+1;
$curPos = strPos($tmp, "\", $nextOffset);
}
$appPath = getSubStr($tmp, 0, $nextOffset);
$TextCompileFile = getSubStr($TextCompileFile, strLen($appPath), strLen($TextCompileFile));
$TextCompileFile = strReplace($TextCompileFile, "\", "/");
compile($TextCompileFile);
$i++;
}
else
{
error("BAD TESTCOMPILE SYNTAX");
}
error("\n\n\n\n\n\nEND TEST COMPILE=================");
error("===========================");
quit();To set textpad up, make a new tool in preferences, mine is "test compile torque script"
set it up with the following options:
command: your app, mine is "F:\USR\people\unearthedgames\ProjectLazarus\Prototype\ProjectLazarus\ProjectLazarus_Internal.exe"
parameters: -testCompile $File
initialFolder: your app folder, mine is
"F:\USR\people\unearthedgames\ProjectLazarus\Prototype\ProjectLazarus\"
I dont' have anything else checked.
All done, then just open up the script file you want to compile and choose the tools->"test compile torque script" option.
It will do a quick run of your app compiling the script and the results will be output in console.log
a good compile might look like this:
Quote:
snip------
===========================
TEST COMPILE=================
Compiling UEG_thetower/server/scripts/game.cs...
END TEST COMPILE=================
===========================
snip------
and a bad compile might look like this:
Quote:
snip------
===========================
TEST COMPILE=================
Compiling UEG_thetower/server/scripts/conversations.cs...
UEG_thetower/server/scripts/conversations.cs Line: 720 - Syntax error.
>>> Advanced script error report. Line 1439.
>>> Some error context, with ## on sides of error halt:
opt_func[0] = "";
opt_nextConv[0] = "ConvWorldInteract1";
}
new ##S##criptObject(ConvWorldInteract4)
{
class = "ConversationNugget";
>>> Error report complete.
END TEST COMPILE=================
===========================
snip-------
I tried to compile main.cs itself and it has an error compiling, but that's ok for me since everything else worked fine.
Also of note: for the script paths, the above code uses whatever $userMods is set to for the modpaths when that option is parsed. Something to keep in mind if it's not finding the scripts.
WARNING: the code above assumes the paths are coming in windows format with \'s and not /'s. if you are using /'s the above code will loop infinitely, it'd be easy to fix with a couple sanity checks but it's not there yet.
#4
07/27/2005 (7:12 pm)
It looks like anything within my mod path is working fine, but anything in common or the root of the app is failing to compile.
#5
BTW, nice work. Lots of fast progress. Make a resource out of this!
07/27/2005 (10:52 pm)
Can't load files that aren't in mod path.BTW, nice work. Lots of fast progress. Make a resource out of this!
#6
07/30/2005 (1:57 pm)
Thanks Ben.
Associate Kyle Carter
That's a pretty clever idea, actually. I use TextPad myself, let me know when you have this working. :)