Page 1 of 1

Adding comments to scripts

Posted: 22 Feb 2018 00:41
by Econdoc
I remember seeing somewhere on this site an example of multi-line comments in a script. Something along the lines of:

/*
this is a block
comment that
extends for several
lines
*/

First, I cannot find any reference to this kind of commenting. Can you directly me to it?

Second, it does not seem possible to have multiple blocks of comments like this. Somehow or other, the block markers (/* and */) seem to get ignored. Entire blocks of script are then included as part of the comment and cannot be recovered. Not good!

What am I doing wrong?

Re: Adding comments to scripts

Posted: 22 Feb 2018 06:23
by Desmanto
It is at the script help or at the website too
https://automagic4android.com/en/help/c ... ion_script

I use this occassionally. Sometimes the highlighting simply fail to gray out the commented lines, it appears to be all white text (not commented). But if you save, exit and reopen the script, those lines grayed out properly.

Do you have the step to reproduce the problem? I remember there is problem if you have no space before the the commented line. Such as

Code: Select all

/*x = 1;
y = 2;*/
But if you put space before the x and after the semicolon (;), the commented lines work properly. But I can't reproduce it now anymore.

Re: Adding comments to scripts

Posted: 22 Feb 2018 08:17
by Econdoc
As always, thanks Desmanto. You are a living encyclopedia!
While I cannot reproduce the problem that I had, I have found a work-around.

First I will describe the problem.
In a Control UI, I had a long block of comment lines, maybe 10 lines long bordered by /* and */. Below the comment block, I had a script with about 40 lines of code. Everything looked okay until I added another long comment block with /* and */. At that point the script became part of the comment...all greyed out and disabled. Removing the second comment block did not work; the script was still greyed out.

Here is how I fixed it. I marked the comment blocks and cut them and pasted them right back where the work. Voila! script lines came back to life again.

This is clearly some kind of bug.

Re: Adding comments to scripts

Posted: 22 Feb 2018 15:09
by Desmanto
So it happens to you as well. You just use a different workaround.

I can't remember how to reproduce this problem. It seems to be intermittent till now. Maybe next time if I came across the same highlighting problem, I will try to repeat the step of producing the problem.