Adding comments to scripts

Post your questions and help other users.

Moderator: Martin

Post Reply
Econdoc
Posts: 153
Joined: 28 May 2016 20:06

Adding comments to scripts

Post by Econdoc » 22 Feb 2018 00:41

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?

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Adding comments to scripts

Post by Desmanto » 22 Feb 2018 06:23

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.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Econdoc
Posts: 153
Joined: 28 May 2016 20:06

Re: Adding comments to scripts

Post by Econdoc » 22 Feb 2018 08:17

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.

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Adding comments to scripts

Post by Desmanto » 22 Feb 2018 15:09

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.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Post Reply