View Full Version : Punctuation nightmares
Have been experimenting with applying scripts to my own game creations to get a feel for how it all works.
about 99% of all the scripts I write come up with an error of some sort....while they are technicly written correctly just about every error is due to a missing ; or " or , and in a few cases I missed one of these )
I figure punctuation is probably the bane of most programmers so most of you have already been through this issue. Can anyone give me some tips/advice on how I can reduce the number of grammer mistakes I make in my scripts or even tips on how to find such mistakes because I find them incredibly difficult to spot even when I'm looking for them.
Here's an example, I can look at the below line of code for 10 minutes before I figure out what's wrong with it :
if(idx==ObjFind(100)
But once I finally notice the missing ) on the end, I can't help but see it...it's like a thumb that was smashed by a hammer. But untill I actually notice it I can study that one line for god knows how long and not see the error.
Is there some kind of magic trick to correcting your grammar,...or is it just something that comes with time and practice?
God only knows I suck at grammer when writing plain english, but that don't matter too much when humans are reading it since the human brain is a bit more advanced than the average processor. The human brain can fill in the blanks whereas a processor can't.
Of course the human brain filling in the blanks may be part of the reason why I don't see the missing punctuation straight away.
i know exactly how you feel. when i first started, i had a hell of a time trying to fix all the errors like that.
even now, if i've coded a large section, i'm amazed if it actually works first time without any errors.
the thing to realise is that the error message helps you. so if you get something like:
PARSER, 0,0, "parse error, expecting`';"
Data\Scripts\game.gs : 777
you know from the second line that the error is in game.gs on line 777. you can then easily go to line 777 and work out what's wrong with it. bear in mind if you're missing a ; the engine will often not notice it until the <i>next</i> line, so in this case, you're looking for line 776.
i think the log can also help, but i've never really used that! :P
EDIT:: a trick to identifying the problem in a line of code is to compare it to a similar line of code, to see what the differences are.
Finding line #776 or #777 could be a big enough chore in itself depending on the text editor you use for your scripts, I use notepad for mine which doesn't tell you which line you're on.
I suppose I could use comments every 10 lines or so to tell me where I'm at :
// line 10
// line 20
// line 30
// etc...
Does anyone else do that?
Which raises another question,...since the CPU ignores comment lines does it still count the line the comment is on?
Hi ! I would recommend free text editor ConTEXT with the DizzyAGE highlighter. See this thread http://www.yolkfolk.com/bb/showthread.php?t=491&highlight=context and then just copy dizzyage.chl file from this thread into the Program files\ConTEXT\Highlighters folder and select this highlighter in the program. Then associate *.gs files with ConTEXT and that's it.
And to your question - yes, comments line are counted too. In practice, every line of source code is counted.
i simply use Notepad. :p
there is a menu option under 'edit' called 'goto', you simply put the line number in and it moves the cursor there. :)
Well, I'll be damned......I've used notepad for this and that for better than 10 years and I didn't even know that:v2_dizzy_confused2:
Learn something new everyday I guess /shrug
xelanoimis
03-03-08, 12:18 PM
As Jamie said, the DizzyAGE script compiler usually points you at the right line, where the error is. However, even with smarter compilers, there might be some errors where the line is not pointed correctly and there is where the experience comes in handy.
As an advice, compile as often as you can, to avoid writing pages of code and then sink in fixing lots of errors. If you only added one function and now you're game doesn't compile, it's there you should look for the error. If the reported error line is not relevant, try to remove parts of the function and see if it works.
Another thing important with the DizzyAGE script is that some errors will not be triggered untill that part of the code is executed. For example, if you call a function that was not defined (or you misspelld it's name), the script will compile fine, but it will report the error when that call is acctually executed, during gameplay. So always test your code in game to see if it trully works.
As for the two numbers reported after the error name (PARSER, 0,0, ...) they have some internal meaning that could help you spot the error, but this is more advanced stuff, that usually it's not necessary to fix normal errors.
Work in developer mode (dev=1 in dizzy.ini) and check the messages in the console ( the ` or ~ key). You can also use the println command in code to trace execution problems (println("test"); or prinln("myvar=",myvar); to see the value of a variable). Remove these println commands in the final game build.
Alex
Another thing important with the DizzyAGE script is that some errors will not be triggered untill that part of the code is executed.
I've run into one like that, When I was going through the tutorial in the dizzyAGE manual, During a long dialouge:
// After initial dialouge but before talking to Denzil
Message2(3,8,"Dizzy,why are you here?");
MessagePop();
Message2(3,8,"You're supposed to be \ntalking to Denzil!");
MessagePop();
Message1(14,6,"Hmmm...Daisy?");
MessagePop();
MessagePop(3,8,"What dear?");
MessagePop();
Message1(14,6,"Maybe we should start \ndating other people");
MessagePop();
Message2(3,8,"Daisy looks at you \nin disgust!");
MessagePop();
Where I used the MessagePop command instead of Message2
Didn't know about it untill the game crashed,...that was more or less just a case of paying attention to where the game crashed and checking the code for that part,.....thankfully that was an easy one to find.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.