mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2012
Posts: 321
Epic Offline OP
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Jan 2012
Posts: 321
In many programming languages or when editing a configuration file, the "#" symbol is commonly used to add single line comments between lines of code.
When writing scripts, it is suggested to use this symbol for the same purpose of adding explanatory comments, but only on the condition that it is the first at the beginning of each new line of code.

Sample code:
Code
on *:TEXT:*:#channel:{

  # creating variables with text
  var %text1 Command action: "!command1"
  var %text2 Command action: "!command2"

  # explanatory commentary on the first command
  if ($1 == !command1) {
    msg $chan %text1
  }

  # explanatory comment to the second command
  if ($1 == !command2) {
    msg $chan %text2
  }
  
}



🌐 http://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Hrm, I tested to see what the current behavior is, and I don't see this change interfering with backwards compatibility.

When executing test_alias, the 1st line either executes the /test alias if not invoked from a channel editbox, or otherwise it tries to execute the channelname as an alias with test as the command line. The 2nd command always invokes the # alias. So, allowing # to be a comment shouldn't interfere with what scripts are doing.

Something else that's equivalent of what you're wanting to do is having REM be the 1st word of the line, where it turns that line into a REMark. I didn't find this documented, but I stumbled across it when I tried to create an alias named rem.

alias test_alias {
# test
$chr(35) test
}
alias # {
echo -a hashtag alias $1-
}

Joined: Jan 2012
Posts: 321
Epic Offline OP
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Jan 2012
Posts: 321
Something I am unable to implement this in my example code using the method you presented.

When typing the command "!command1" on the channel in the status window writes 3 similar lines:
Code
#CHANNEL Unknown command



🌐 http://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples
Joined: Apr 2004
Posts: 871
Sat Offline
Hoopy frood
Offline
Hoopy frood
Joined: Apr 2004
Posts: 871
I don't understand. What is wrong with the semicolon? Why do you want another character for the same thing?


Saturn, QuakeNet staff
Joined: Jan 2012
Posts: 321
Epic Offline OP
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Jan 2012
Posts: 321
Alternatively equals with the same semicolon "#" = ";". So that, in this way, this commenting can be similar to coding as in other languages, and so that it cannot cause similar errors.
This may be more convenient for those who are used to commenting their code in this way, and it simply stands out much better against the background of large multi-line code.
And in particular, it would be more convenient for me.

I don't think it's so difficult to implement, and certainly not more difficult than the questions that are asked here and are resolved on a daily basis.
But if this is difficult to do, then it's okay. The main thing is that I voiced my idea in the correct section of the forum as a possible solution to further improve the mIRC client.


🌐 http://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples
Joined: Apr 2004
Posts: 871
Sat Offline
Hoopy frood
Offline
Hoopy frood
Joined: Apr 2004
Posts: 871
Fair enough!


Saturn, QuakeNet staff
Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
AFIAK, the hash/she/pound symbol is being used for directives. The only directive mSL has right now is Groups via /enable and /disable, but it pretty much prohibits this character from being used for commenting because any arbitrary string can be used in group names.

Code
#Is_This_A_Comment On
On *:START: echo -a Hello World
#Is_This_A_Comment End


Afraid it would be impossible without first making Groups obsolete.


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Epic, I was not giving a method to implement # as a comment character. I was showing how using it as a comment character shouldn't interfere with typical usage, unless someone somehow needed to have an alias named #mirc that works only in all channels but can't be used in @window or status window editboxes. The only way to reliably call the alias named # is to call it like the alias $chr(35) or as the identifier $#, and even if someone did have a custom alias named #, they would not be trying to invoke it by having #<space> be at the beginning of a line.

The closest you could currently get mIRC to implementing # as a comment would be to have it behave like /noop which would still have its command line be evaluated. Doing that would require an ON JOIN event which creates a dummy alias named after that channel each time you join a channel.

edit: actually the # as a comment couldn't be faked using an alias matching the name of each channel you're in, because when invoked in a context where $chan is $null, the 1st word following the # would still be seen as if it's an alias name.

Last edited by maroon; 10/04/21 04:43 PM.
Joined: Sep 2015
Posts: 101
Vogon poet
Offline
Vogon poet
Joined: Sep 2015
Posts: 101
Non-sense! Because someone loves # so Khaled must change ; to # ? But i love ; and what to do? Epic, don't be egoist and think not only for you.

Joined: Jan 2012
Posts: 321
Epic Offline OP
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Jan 2012
Posts: 321
Actually, if you carefully read the previous posts, then I wrote that it may be needed by someone else besides me, but not necessarily for implementation, and can only help expand the ways of commenting the code.
Also, this is will not replace the normal commenting method, but can only be an addition to the existing method as an alternative.

If I propose such ideas, it is not for my own sake, but for the sake of expanding the scripting language in the interests of other scripters, and this does not bring any significant change in the general syntax.
So personally, you can continue to comment on your scripts further in the way that suits you best using a semicolon ";".

And besides, here there are many who offer something and i don't think these proposals are a manifestation of any selfishness, but are just ideas for the further improvement of the client.
With the same success it can be said that all your own proposals or requests, left earlier in this forum, were a kind of manifestation of selfishness in order to achieve their own interests, but this is not so.
I left my proposal on the forum in an appropriate and appropriate for this section, only for consideration as a possible additional solution for ease of coding.

In the end, no one forces or obliges anyone, this is just an idea for thought. All my suggestions are always aimed only at general improvement and for the usability of the mIRC client.

P.S. Henceforth, I ask you to read my posts carefully before leaving your comments.




🌐 http://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples
Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
I'd suggest requesting features that you yourself find eminently useful and important. As opposed to what you think other people might possibly find handy if the planets ever align. That's just my observation.


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Joined: Jan 2012
Posts: 321
Epic Offline OP
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Jan 2012
Posts: 321
I have already left here quite a few requests, ideas and interesting proposals, but apparently, the time has not yet come "the alignment of the planets in one line", to implement this. (In my observation).


🌐 http://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples
Joined: Feb 2009
Posts: 25
W
WKN Offline
Ameglian cow
Offline
Ameglian cow
W
Joined: Feb 2009
Posts: 25
Many languages uses // for line comments (Java, Javascript, C, etc.). # is more known to shells or in textbased configs.

More importand then any "new" comment signs would be better string handling by 'str ing' or "str ing"

Joined: Jan 2012
Posts: 321
Epic Offline OP
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Jan 2012
Posts: 321
It is truth too. I agree. In generally, it would be convenient if there was a wide enough choice of ways from different symbols, which programmers know and usually use to comment out lines.
But if to date this is a rather difficult task or insignificant, then this idea can be postponed for future versions, or just forget.


🌐 http://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples
Joined: Nov 2004
Posts: 842
Hoopy frood
Offline
Hoopy frood
Joined: Nov 2004
Posts: 842
# is already used for groups (something I do actually use), so I don't see this happening without breaking everyones scripts.


What do you do at the end of the world? Are you busy? Will you save us?
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
# as a word is not used by groups, so it would not interfere with that. Groups use lines like

#groupname on
code
#groupname end

... so the # as a separate word only is used as an alias for $chan, and since that should not be used as the first 'word' of a script line, it shouldn't interfere with that either.

Joined: Jul 2006
Posts: 4,180
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,180
Hello, I disagree strongly and entirely:

Quote
In many programming languages or when editing a configuration file, the "#" symbol is commonly used to add single line comments between lines of code.

mIRC is using the famous C comment /* */, which almost all major programming language i can think of, support, C C++ javascript mIRC C#, probably a lot more. # seems to be used in python, not sure else where, seems to me like # for commenting out is way less used than /* */ (plus, they do have the requirement that /* start the line in mIRC, same as # then). So right at the start, there's no such thing as # being commonly used compared to mIRC's way of commenting with /* */

Quote
Alternatively equals with the same semicolon "#" = ";". So that, in this way, this commenting can be similar to coding as in other languages, and so that it cannot cause similar errors.
This may be more convenient for those who are used to commenting their code in this way, and it simply stands out much better against the background of large multi-line code.
And in particular, it would be more convenient for me.
Here you repeat that it would be similar but it's the same demonstration as above, mIRC is already being similar to most languages, adding another character would actually create lot of issues, it wouldn't stop causing some hypothetical issues you're not even mentioning to stop being there.

All in all it would be handy for you to have it, but only you so far.

Now, I am against this suggestion for any character, but it has been demonstrated on multiple sides that # will break backward compatibility, either because of groups or because of # being treated as $chan (so if $chan has a value, it should execute that alias)

Even if all programming language where using # and mIRC weren't and already had something others than /* */ or ; or rem, I'd still be against it because the functionality would be already there, it's not offering anything, you're just bloating the language


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Dec 2002
Posts: 5,477
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,477
In general, if a feature already exists, eg. ; /**/ and REM can currently be used for comments, I will not add another method unless there is a really good reason for it. In addition, the # character would not be a good candidate here as it is already used in other contexts and I would not want to overload it further. Thanks for your comments everyone.


Link Copied to Clipboard