[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
Orfevs
Posts: 183
Joined: Thu, 22. Jan 09, 23:03
x3tc

[WiP]Syntax - Editor - Comments

Post by Orfevs »

(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
X2-Illuminatus
Moderator (Deutsch)
Moderator (Deutsch)
Posts: 25041
Joined: Sun, 2. Apr 06, 16:38
x4

Post by X2-Illuminatus »

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

*  <'&'>
codearray:

Code: Select all

<sval type="string" val=" &lt;'&amp;'&gt;"/>
So, it seems that this problem was fixed from X3R to X3TC.
Nun verfügbar! X3: Farnham's Legacy - Ein neues Kapitel für einen alten Favoriten

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, Nopileos, X3: Yoshiko as Kindle e-books!
Orfevs
Posts: 183
Joined: Thu, 22. Jan 09, 23:03
x3tc

Post by Orfevs »

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”