mIRC Home    About    Download    Register    News    Help

Page 1 of 2 1 2 >
Topic Options
#234914 - 15/11/11 01:00 AM -un of /set for /var
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3462
Loc: France
Since we can now use var -g to set several global variable, it would be nice to be able to use the -u switch of /set with /var.
The -n switch is also something I would like to be able to use
_________________________
Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net

Top
#234942 - 17/11/11 01:19 AM Re: -un of /set for /var [Re: Wims]
argv0 Offline
Planetary brain

Registered: 13/10/03
Posts: 3918
Loc: Montreal, QC, Canada
-u doesn't make sense in a local variable (because of the way mIRC triggers timer events and the single threadedness of script execution, -u can never actually trigger until the alias ends anyway). I assume this is to be used with -g, so if you need to set a global variable with an unset timer, why not just use /set? As far as "plain text" goes, just use $(text,0). If you want the features of /set, just use /set.
_________________________
- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"

Top
#234944 - 17/11/11 02:13 AM Re: -un of /set for /var [Re: argv0]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3462
Loc: France
Quote:
I assume this is to be used with -g
Indeed:
Originally Posted By: Wims
Since we can now use var -g to set several global variable

Quote:
why not just use /set
Because it totally defeats the purpose of using var -g, I wouldn't suggest it otherwise.
Quote:
As far as "plain text" goes, just use $(text,0). If you want the features of /set, just use /set.
No, the -n switch let you prevent the calc feature, ie "var -s %a $(1 + 2,0)" displays 3. The -l switch of /set is undocumented so arguing that I should use /set with an undocumented switch to use -n to make a local variable make little sense, and it is also against the point of using var -g.
_________________________
Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net

Top
#234945 - 17/11/11 08:12 AM Re: -un of /set for /var [Re: argv0]
Wiz126 Offline
Babel fish

Registered: 22/03/10
Posts: 57
Originally Posted By: argv0
-u doesn't make sense in a local variable (because of the way mIRC triggers timer events and the single threadedness of script execution, -u can never actually trigger until the alias ends anyway).

Actually, -gu would be rather very handy for cross-alias local variables. Many scripts currently use /set -u %var foo (for things like multiple returns and such) ; simply expending that feature for /var would be a nice addition.

Originally Posted By: argv0
As far as "plain text" goes, just use $(text,0). If you want the features of /set, just use /set.

Not only does that not work (var -s %x $(4 + 1,0) => * Set %x to 5), but for most cases where you actually do need to evaluate it as plain text, you can't really use $(,0) since you want to evaluate things. Of course, like always, obscure workarounds exists. But that's what they are, workarounds.

Being able to use all these features with multiple variables are the entire point of that feature suggestion.


Edited by Wiz126 (17/11/11 08:42 AM)

Top
#234946 - 17/11/11 01:26 PM Re: -un of /set for /var [Re: Wims]
argv0 Offline
Planetary brain

Registered: 13/10/03
Posts: 3918
Loc: Montreal, QC, Canada
Originally Posted By: Wims
The -l switch of /set is undocumented so arguing that I should use /set with an undocumented switch to use -n to make a local variable make little sense


What?? So you're not allowed to use undocumented switches now? If anything, you should be opening a bug report to document -l, not asking for a new feature because an existing feature is currently undocumented. If you know about the feature, you should use it, the fact that it is undocumented is likely an oversight, not an implication that you should be avoiding it. Indeed, if you want the behaviour of -n, you should be using /set -l. There's no need to have the same behaviour in different places. The only argument I could see would be the ability to set multiple global variables with a timer at the same time, but IMO that argument doesn't really stand up to practicality. The fact is we already have a way to do exactly what you need, so it seems to me as though you're just requesting this feature for the sake of keeping Khaled busy. I'd like to think he has better features to work on than adding new ways to do the same things.
_________________________
- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"

Top
#234947 - 17/11/11 01:35 PM Re: -un of /set for /var [Re: Wiz126]
argv0 Offline
Planetary brain

Registered: 13/10/03
Posts: 3918
Loc: Montreal, QC, Canada
Originally Posted By: Wiz126
Being able to use all these features with multiple variables are the entire point of that feature suggestion.


Except that you couldn't use -n with multiple variables, so it's not the "point"-- that would defeat the purpose of the "treat data as plaintext" concept. In other words, if -n was used, mIRC could not be able to tell that a "," was used to separate variables, because it's supposed to be treating the data as plain text-- that's what you asked for, right? Otherwise you would need -n and yet another "REALLY, I MEAN PLAIN TEXT!" switch to tell mIRC not to parse ", %var2 = .... " as anything special.

The only thing you COULD use multiple variable setting for would be with -gu, but as I said above, you can already do this. Yes, I agree it's more elegant to user /var over multiple /set's, but let's not kid ourselves, this is mIRC script-- "more elegant" doesn't really hold much weight, IMO. The way I see it, if you can script it with /set and it's not horribly inconvenient (/set is not significantly more inconvenient, in this case), why do we need this? "Just cause"? Seems like there are better things Khaled should be focusing on.
_________________________
- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"

Top
#234948 - 17/11/11 02:19 PM Re: -un of /set for /var [Re: argv0]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3462
Loc: France
Quote:
so it seems to me as though you're just requesting this feature for the sake of keeping Khaled busy. I'd like to think he has better features to work on than adding new ways to do the same things.
Rather for convenience than anything else (var -g was added for that reason no?) and it just seems weird to use an undocumented switch that is, afaik, only supposed to be used internally.

But you have a good point with -n meaning it should treat value as plain text, causing issues when setting multiple variable with /var. The routine could be extended though I admit it might not be a good idea
_________________________
Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net

Top
#234954 - 17/11/11 04:21 PM Re: -un of /set for /var [Re: argv0]
Jigsy Offline
Hoopy frood

Registered: 18/11/04
Posts: 798
Loc: I live inside your computer. S...
Originally Posted By: argv0
why not just use /set?


Code:
var -gu3 %1 = 1, %2 = 2, %3 = 3, %4 = 4

vs.
Code:
set -u3 %1 1 | set -u3 %2 2 | set -u3 %3 3 | set -u3 %4 4


Which would you prefer to do?

So I support the idea of -guN.
_________________________
This signature is currently out of order. We apologize for the inconvenience.

Top
#234959 - 17/11/11 10:14 PM Re: -un of /set for /var [Re: Jigsy]
pball Online
Fjord artisan

Registered: 04/11/09
Posts: 295
I personally prefer /set and would use your second example. I just feel that setting multiple vars on a single line can make the code harder to read. Like when debugging other peoples code (which I usually just ignore and code from scratch any more, for many reasons).
_________________________
http://scripting.pball.win
My personal site with some scripts I've released.

Top
#234961 - 18/11/11 12:18 AM Re: -un of /set for /var [Re: pball]
Jigsy Offline
Hoopy frood

Registered: 18/11/04
Posts: 798
Loc: I live inside your computer. S...
Originally Posted By: pball
I just feel that setting multiple vars on a single line can make the code harder to read.


Really? I got that vibe from my second example...
_________________________
This signature is currently out of order. We apologize for the inconvenience.

Top
#234962 - 18/11/11 12:54 AM Re: -un of /set for /var [Re: Jigsy]
argv0 Offline
Planetary brain

Registered: 13/10/03
Posts: 3918
Loc: Montreal, QC, Canada
I actually see the set as more readable, but even if we disagree, I see that example as somewhat of an edge case. You're not going to see that kind of code a lot (you shouldn't anyway), and if you do and it looks ugly, it's probably because it shouldn't exist. Setting a whole boatload of global variables on timers smells of bad code to me... I really doubt that would be the worst of the readability issues in such a script. Of course, that's no reason not to add it, but like I said, IMO these scenarios are fairly uncommon-- why optimize readability on the uncommon scenarios?
_________________________
- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"

Top
#234965 - 18/11/11 02:47 AM Re: -un of /set for /var [Re: Jigsy]
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8327
Loc: MA, USA
The second option is more readable to me as well. Yes, the first one is shorter, but the second is more clear imo.
_________________________
Invision Support
#Invision on irc.irchighway.net

Top
#234966 - 18/11/11 05:02 AM Re: -un of /set for /var [Re: argv0]
argv0 Offline
Planetary brain

Registered: 13/10/03
Posts: 3918
Loc: Montreal, QC, Canada
I should point out that in a script file I rarely stack multiple commands on the same line in the first place unless it's only 1 or 2 commands (and would recommend others did the same), so it would actually look more like:

Code:
set -u3 %1 1
set -u3 %2 2
set -u3 %3 3
set -u3 %4 4


Actually, I'd find it hard to argue that this is less readable than var.

As a sidenote, if you really DID need to unset multiple variables at the same time, perhaps /set -u isn't even the best way to go. I'd probably do:

Code:
%myscript.temp.foo = somevalue
%myscript.temp.bar = someothervalue
%myscript.temp.baz = lastvalue
.timer -o 1 3 unset %myscript.temp.*


Not sure which one is easier to read, the latter is easier to maintain, though.

And you could do the same with /var -g and /timer, of course.
_________________________
- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"

Top
#234967 - 18/11/11 05:37 AM Re: -un of /set for /var [Re: argv0]
jaytea Offline
Fjord artisan

Registered: 23/02/06
Posts: 546
The purpose of the '-n' switch is to prevent the value, after regular evaluation, from being interpreted as a calculation.

I can't check right now, but I'm sure /var -g still calls /set several times as is typical of /var. Having all extra switches supplied with -g passed on to /set would be trivial to implement and would improve the command, imo.

(I couldn't follow the thread on my phone very well so apologies if I missed something :p)

_________________________
"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde

Top
#235009 - 20/11/11 06:50 AM Re: -un of /set for /var [Re: Riamus2]
Tomao Offline
Hoopy frood

Registered: 07/07/07
Posts: 1129
Loc: United States
At the end of the day, it all depends on what you see fit. We all see things differently with our distinctive tastes toward them. You may see a guy being handsome or a girl being ugly, but other people may perceive them being easy on the eyes.

Top
#235057 - 21/11/11 02:20 PM Re: -un of /set for /var [Re: jaytea]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3462
Loc: France
My original suggestion for -n was about /var -n only, not var -gn.
I thought like argv0 that it would be a problem but in fact, each assignement is probably known/done before -n is applied, so it is actually possible to implement var -n on its own.
But sure -gn should also be supported.
_________________________
Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net

Top
#235069 - 21/11/11 07:01 PM Re: -un of /set for /var [Re: argv0]
hixxy Offline
Hoopy frood

Registered: 06/09/05
Posts: 2876
I'm not sure why you feel the need to argue with almost every suggestion or bug report people make. This is a perfectly reasonable suggestion and there's absolutely no reason why it shouldn't be implemented.

/var -g allows you to create a global variable, so it should have the same features as /set does. There's not really any reason why it shouldn't. And I doubt something this trivial will be "keeping Khaled busy."

If you have nothing useful to say, don't say anything.

Top
#235096 - 22/11/11 10:27 PM Re: -un of /set for /var [Re: hixxy]
argv0 Offline
Planetary brain

Registered: 13/10/03
Posts: 3918
Loc: Montreal, QC, Canada
Note that I'm not disagreeing with the suggestion, I'm simply offering simple alternatives. I'm of the opinion that we should keep feature bloat as low as possible and not duplicate functionality across different functions unless there is a significant improvement in the API. In this case I don't see a significant improvement.

I think it's useful to point out that you can already do this with /set, just not with multiple vars at once, but the use-case for multiple vars at once is yet to be seen. As I mentioned, you might see the need for this once or twice in a script. But would you really break your scripts back-compat (seeing as this wouldn't work in 7.22 and earlier) just for a completely cosmetic change that occurs once in your entire script?

I also don't buy the argument that we should add this "because /set has it". /set -l can create local vars, so should we be adding multiple assignment to /set, then? Why should /var have the same features as /set if /set doesn't have the same features as /var? It seems to me that the reason different commands have different features is precisely because they are different commands. Yes, you would get multi-assign by adding the functionality of /set to /var, but again, the actual benefit of this is really not obvious (to me, anyway). It's a nice thought that when something is a small change it's easy to just do it in addition to everything else Khaled is doing. But realize that ultimately, Khaled's time is limited, and ultimately, he will be deciding to implement this instead of something else, for the next version. I'd rather see him squash some small but much more important bugs like this, which is likely to take as much time to fix/test.
_________________________
- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"

Top
#235097 - 22/11/11 10:37 PM Re: -un of /set for /var [Re: argv0]
hixxy Offline
Hoopy frood

Registered: 06/09/05
Posts: 2876
I'm not sure both of the commands need identical features, but there's no point in having both commands with a unique feature. Might as well have one command that does everything and one that is limited (if they're not both going to have every feature).

At the moment you have one command for setting global timed variables, and one command that lets you set multiple variables at a time. Might as well have at least one of those commands support both.

Plus Khaled can manage his own development plan; I wouldn't let that concern you. Just comment on the feature suggestion itself rather than whether you think it's a waste of Khaled's time.

Top
#235099 - 22/11/11 10:48 PM Re: -un of /set for /var [Re: hixxy]
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8327
Loc: MA, USA
argv0 still makes a great point that if you were to use something like this, which is highly cosmetic rather than actually beneficial, that you would be limiting your script to only newer versions of mIRC. Maybe a scripter wouldn't care about that, but I think most people want to maintain compatibility with older versions as much as possible until it becomes inconvenient such as not being able to use $v1 (something that is very beneficial).

As to your first comment about two commands... based on your thought that one command should do everything, then why bother having two commands at all? If you're going to use that reasoning, then let's just drop one altogether and put everything into one command. Sure, it breaks scripts, but it is better than saying that one command should do everything and the other should do very little. Either two commands should do two different things, or there should be one command.
_________________________
Invision Support
#Invision on irc.irchighway.net

Top
Page 1 of 2 1 2 >