EnglishGermanFrenchRussianPolishItalianSpanish
Log inRegister
 
[WiP]Syntax - Editor - Comments
Post new topic Reply to topic
View previous topic :: View next topic
Author Message
Orfevs





Joined: 23 Jan 2009
Posts: 179 on topic

Thank you for registering your game
PostPosted: Fri, 13. Apr 12, 16:38    Post subject: [WiP]Syntax - Editor - Comments Reply with quote Print

(This may seem like a redundant topic to many, but it cannot be emphasized enough)

* this is a Comment

Is anyone up for practical examples on what NOT to do? Something that'll crash my compiler or script please...

Starting the line with an asterisk '*' will make the rest of the line a comment. It is the only way of commenting within the script.

While this is amongst the very first things you figure out, there is a caveat. It is generally warned against using certain characters in the comments. If you use Exscriptor, then you're already familiar with the warnings. The characters:
  • & ( ampersand, "and" )
  • < ( Angled starting bracket, "lesser than" )
  • > ( Angled closing bracket, "greater than" )
  • ' ( Single quote )

The logical explanation is that the scripts themselves are XML coded, something that will be apparent when you view them in an ordinary text viewer. XML uses < and > excessively for initiating and terminating codes respectively. & <alias>;is used as alias for XML specific characters as described next.
MSCI and Exscriptor converts these characters into it's xml aliases

  • &amp;
  • &lt;
  • &gt;
  • &quot;

to avoid mishaps. ESCE does not.

What could happen if you use special characters in comments?
The answer is - Anything!
First of all, your script could cease to load, or not wanting to save properly if at all. What's usually caught by the editor's error checker could slip right past and say everything's hunky dory. Then when you run your script, there's no telling what's wrong, since you're sure you did everything correctly and by the book. Except for the comments.

It is also advised against getting too creative in your comments - even if they don't include characters with XML aliases. You are after all editing a script, not an ascii drawing board.

Back to top
View user's profile Send private message
X2-Illuminatus
Moderator (Deutsch)
Moderator (Deutsch)

MEDAL

Joined: 02 Apr 2006
Posts: 19841 on topic

Thank you for registering your game
PostPosted: Fri, 20. Apr 12, 17:56    Post subject: Reply with quote Print

Hmm, I'm using the special characters you mentioned in comments in my scripts sometimes, but honestly I've never encountered any problems with them. Neither in X3TC nor X3AP.
Looking through the forums, I found this bug report by Gazz and this explanation by Cycrow, both for X3R. The original problem was that the > and < signs were not converted to their xml-aliases and were therefore interpreted as xml-start/end-tags. However, nowadays (TC and AP) the signs are converted correctly.

sourceplaintext:
Code:
*  <'&'>


codearray:
Code:
<sval type="string" val=" &lt;'&amp;'&gt;"/>


So, it seems that this problem was fixed from X3R to X3TC.


_________________
Ab sofort verfügbar: Farnhams Legende und Nopileos als E-Books!

"People who think they know everything are a great annoyance to those of us who do." - Isaac Asimov
Back to top
View user's profile Send private message Visit poster's website
Orfevs





Joined: 23 Jan 2009
Posts: 179 on topic

Thank you for registering your game
PostPosted: Sat, 28. Apr 12, 03:23    Post subject: Reply with quote Print

Commenting like this:
Code:

* $null -> START "scriptname" :


hasn't produced any problems on my part in TC and up. Only problem is that the compiler renames the symbols to aliases on save:

Code:

* $null -&lt; START "scriptname" :


Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic Reply to topic
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum
Control Panel
Login Data
The time now is Mon, 24. Apr 17, 01:34

All times are GMT + 2 Hours


Board Security

Copyright © EGOSOFT 1989-2017
Powered by phpBB © 2001, 2005 phpBB Group
Template created by Avatar & BurnIt!
Debug: page generation = 0.20921 seconds, sql queries = 17