mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2012
Posts: 301
Epic Offline OP
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Jan 2012
Posts: 301
I've got a wonderful idea [Linked Image from i.ibb.co]

It would be nice if when editing the script after adding a new condition and writing an "if" command, empty round parentheses and empty curly brackets would be automatically added.
In any case, these are mandatory parameters, even when it is done manually without autocomplete, but with automaticity it seems to me it will become more convenient.
It will be similar to code editing, as in any development environment, where there are usually some analogous autocomplete features.
Quote
if () {}

What are the benefits of this solution:

  • All novice scripters will always get the correct construct when creating a new condition.
  • This will prevent a common beginner's scripters error where they forget to close different open brackets.
  • This will speed up the overall editing of the script a bit when creating numerous new conditions.



So in code it might look like this:
Code
on *:TEXT:!test:#test:{
  if () {}
  msg $chan test message
}

But if the code is left like this, it will throw an error message on the second line "* /if: insufficient parameters (line 2, Test.mrc)" and stop the code from running.
I propose to change this behavior so that in the case of empty brackets in the condition, this does not lead to the script stopping, instead, need to send an echo message with a hint on what line number and in what name of the script is the empty condition and also send command for get help info "/help If then else", which should help novice scripters understand, and it won't break the script. Also when leaving empty curly braces, in my opinion, it is not worth reacting at all, this should not be a mistake, since it can be assumed that the script developer will later fill this emptiness with the necessary commands.

In case this interferes with editing, or some of the older scripters find it redundant, then a new item can be added to the scripts editor options for enable or disable this feature. Set as default enable.


🌐 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
It sounds like what you're saying is that the parenthesis and brackets would appear as soon as you typed

if<spacebar>

This idea would need to be fleshed out, and surely made optional, because if 'identifier warning' is unchecked by default, I would assume this would also.

I'm writing this from the viewpoint of someone who doesn't see themselves as part of the target audience, so would need a little more convincing. (I don't know of the development environment you speak of)

If this option were enabled, I would assume the other environment of which you speak has a way to easily get rid of the inserted string in case they don't want them. Also, this could have an effect on Ctrl+Z/Y undo/redo.

If someone does want to have the parenthesis inserted automagically, I assume the desired behavior would be to move the cursor inside the parenthesis, because it would be simpler to type the parenthesis myself than to

+ find the arrow key or mouse to navigate inside the opening parenthesis
+ type the interior condition
+ find the arrow key to move past the closing parenthesis then navigate inside the curly braces
+ use {END} so I can then {ENTER} to add the next line of code.

Also the desired 'coaching' behavior would probably be to include several spaces inside the auto-added curly braces so that the novice isn't coached into expecting that it's fine for the interior command to touch the curly braces.

Strangely, I found at least 1 edge case where you can have both curly braces touch something and it still works. This is the kind of crazy stuff where requiring the language to support it can make the parser slower. It works whether or not the opening curly touches the preceding text but in either case the closing must touch the parenthesis:

success:
//noop $findfile($mircdir,*,0,1,if *.ini iswm $1 { echo -a $1 })
success:
//noop $findfile($mircdir,*,0,1,if (*.ini iswm $1){ echo -a $1 })

--

If you're proposing this for if(), I wonder what other things in that other environment are you thinking would be relevant here, besides doing the same thing for while()

/while has the same variety of syntax that if() has, and even more-so since it's much more common for the while { condition } to be split across lines.

The idea behind your proposal does have merit. As I've mentioned several times in forum posts, I agree the new scriptors should get in the habit of 'when in doubt use parenthesis', partly because it's easier for them to read their code later, but also because there's several different cases where dropping the parenthesis can change the behavior of $v1, such as here where setting %a to an odd or even number fills $v1 using a completely different if() condition.

//var %a 1 | if (abcd == defg) noop | if %a isin 13579 echo -a $v1 is odd %a | else echo -a $v1 is even %a

Joined: Jan 2012
Posts: 301
Epic Offline OP
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Jan 2012
Posts: 301
I apologize for my English if my words were misunderstood or mistranslated because my native language is Russian, but I hope the main idea of my idea was clearly stated.

Originally Posted by maroon
I don't know of the development environment you speak of
Now I mainly work in the "PyCharm" development environment for programming in the Python language.

Originally Posted by maroon
This idea would need to be fleshed out, and surely made optional, because if 'identifier warning' is unchecked by default, I would assume this would also.
I believe that this innovation in the scripts editor should be enabled by default, because it will be immediately available to beginners, while they have not yet figured out how to use the mIRC settings, but experienced users will immediately figure out how to disable this option if they consider that this option is they don't need it.

Originally Posted by maroon
If someone does want to have the parenthesis inserted automagically, I assume the desired behavior would be to move the cursor inside the parenthesis
Yes, I forgot to mention this, it is absolutely correct and logical that after writing the if command, the cursor focus should be moved inside the newly created empty parentheses: if (|) { }

Originally Posted by maroon
Also the desired 'coaching' behavior would probably be to include several spaces inside the auto-added curly braces so that the novice isn't coached into expecting that it's fine for the interior command to touch the curly braces.
Yes, it would probably be the right thing to add some (2) spaces inside the curly braces to make editing easier and avoid errors: if () { | }

Originally Posted by maroon
/while has the same variety of syntax that if() has, and even more-so since it's much more common for the while { condition } to be split across lines.
Yes, it would also be useful for beginners, so that after writing the while command, the correct loop code structure is automatically created, for later adding your own parameters to it.

For example, the following automatic construction could be created:
Code
var %i 1
while (%i <= 1) {
  
  inc %i
}


Originally Posted by maroon
If you're proposing this for if(), I wonder what other things in that other environment are you thinking would be relevant here, besides doing the same thing for while()
If this idea turns out to be in demand and will be implemented in the beta version, then I will definitely think about what else I can offer useful for editing mIRC scripts. In fact, there can be many more interesting ideas.

Originally Posted by maroon
The idea behind your proposal does have merit. As I've mentioned several times in forum posts, I agree the new scriptors should get in the habit of 'when in doubt use parenthesis', partly because it's easier for them to read their code later.
Thank for your support and due attention to my idea, as well as for additional tips and important comments.


🌐 http://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples

Link Copied to Clipboard