It's all in context though; you are right Jethro_. When used as an operator it utilizes an isMultiple() function of sorts ... when used in conjunction with a command it forces evaluation i.e. //noop $ident(a) $ident(b). But when used with nothing, simply // as it were, then there is no command to evaluate anything for. Same as Jaytea was saying with the empty command bit.
Here, this differs from the last one I pasted in that I simplified it. It also has an example at the end of it to better show it's usage.
It does require that you have .NET 2.0 at least I believe, which is really standard to have these days. Unless you're using linux. :> If that's the case then COM will only work (and terribly I might add) through the use of WINE or some other similar emulation.
alias -l inherits if (!$com($1)) halt
alias -l object { if (!$com($2)) .comopen $2 $1
return $iif($com($2).progid == $1,$2,$null)
}
alias array {
; REM ## Object initialization ##
inherits $object(system.collections.arraylist,$1)
; REM ## Method handling ##
if ($2 == sort ) noop $com($1,sort,1)
if ($2 == clear ) noop $com($1,clear,1)
if ($2 == append ) noop $com($1,add,1,string,$3)
if ($2 == remove ) noop $com($1,remove,1,int,$3)
if ($2 == insert ) noop $com($1,insert,1,int,$3,string,$4)
if ($2 == removeat) noop $com($1,removeat,1,int,$3)
if ($2 == reverse ) noop $com($1,reverse,1)
if ($2 == delete ) .comclose $1
; REM ## Property handling ##
if ($2 == item ) return $null($com($1,item,3,int,$3)) $com($1).result
if ($2 == count ) return $null($com($1,count,3)) $com($1).result
if ($2 == exists) return $null($com($1,contains,3,string,$3)) $com($1).result
}
alias test {
var %a = example, %b = 10
; REM ## Create an array by the name of "example."
noop $array(%a)
; REM ## Populate the array with some data.
while (%b) {
noop $array(%a,append,%b)
dec %b
}
; REM ## Reverse the array.
noop $array(%a,reverse)
linesep
; REM ## Enumerate and echo each item in the array.
%b = 0
while ($array(%a,item,%b)) {
echo -a Item %b $+ : $v1
inc %b
}
linesep
; REM ## Determining the size and whether an item (data) exists or not.
echo -a Count: $array(%a,count)
linesep
noop $array(%a,append,z)
echo -a Exists("z"): $array(%a,exists,z)
linesep
; REM ## Bit sorting the array is the built-in default method shown here.
noop $array(%a,sort)
%b = 0
while ($array(%a,item,%b)) {
echo -a Item %b $+ : $v1
inc %b
}
linesep
; REM ## Clearing and deleting an array.
noop $array(%a,clear)
noop $array(%a,delete)
; REM ## End of test.
echo -a End of test.
linesep
}
There's really no need to be snippy about it. We all know it's your thread and we all know you've pasted three variations. We are just showing you other methods to increase your knowledge by allowing you to see other methods in action. That way you can take it upon yourself to further your own instruction. Obviously, with the reaction you gave, you haven't much desire to take it upon yourself to learn anything past the norm. Since it is such a problem for me to do the same as sunslayer has for you I will remove mine.
It does indeed! Of course, Jaytea is a dictator and won't allow any fun in #mSL anyway!
As a side note to Mr. Jaytea: Some of us still recall the original intent of #mSL and I do like to read over the things you type for all of us 'lesser' (used lightly) people regarding the internal functionality and behaviour of scripting with MSL. So, thanks a lot for explaining yourself here and elsewhere ... always a nice treat! :D