[WiP]Syntax - Editor - Comments

This forum serves as MSCI Reference at EGOSOFT. It's Read-Only for non MSCI Group members.

Moderators: Scripting / Modding Moderators, MSCI Moderators

Post Reply
Posts: 183
Joined: Fri, 23. Jan 09, 00:03

[WiP]Syntax - Editor - Comments

Post by Orfevs » Fri, 13. Apr 12, 16:38

(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.

User avatar
Moderator (Deutsch)
Moderator (Deutsch)
Posts: 21900
Joined: Sun, 2. Apr 06, 16:38

Post by X2-Illuminatus » Fri, 20. Apr 12, 17:56

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.


Code: Select all

*  <'&'>

Code: Select all

<sval type="string" val=" &lt;'&amp;'&gt;"/>
So, it seems that this problem was fixed from X3R to X3TC.
Die komplette X-Roman-Reihe jetzt als Kindle E-Books! (Farnhams Legende, Nopileos, X3: Yoshiko, X3: Hüter der Tore, X3: Wächter der Erde)

Neuauflage der fünf X-Romane als Taschenbuch

The official X-novels Farnham's Legend and Nopileos as Kindle e-books! (NOW also available: X3: Yoshiko!)

Posts: 183
Joined: Fri, 23. Jan 09, 00:03

Post by Orfevs » Sat, 28. Apr 12, 03:23

Commenting like this:

Code: Select all

* $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: Select all

* $null -< START "scriptname" :

Post Reply

Return to “MSCI Reference”