mIRC Home    About    Download    Register    News    Help

Print Thread
Miscallaneous identifiers #141390
09/02/06 01:23 AM
09/02/06 01:23 AM
Joined: Sep 2005
Posts: 2,876
H
hixxy Offline OP
Hoopy frood
hixxy  Offline OP
Hoopy frood
H

Joined: Sep 2005
Posts: 2,876
$rangetok(N,N,asc) - returns a range from N to N separated by asc.
$rangetok(1,5,44) -> 1,2,3,4,5
$rangetok(5,3,46) -> 5.4.3

$reverse(<string>) - returns <string> backwards.
$reverse(hello) -> olleh
$reverse(olleh) -> hello

$blendian(<string>) - converts a string from big to little endian (same as $reverse but swaps every two bytes instead of every byte. Maybe we could specify the number of bytes to swap in $reverse.)
$blendian(1234) -> 3412
$blendian(12345678) -> 78563412

$clsid2progid(<clsid>) - converts a clsid to a progid for use in $com().
$clsid2progid({72C24DD5-D70A-438B-8A42-98424B88AFB8}) -> WScript.Shell
$clsid2progid({0D43FE01-F093-11CF-8940-00A0C9054228}) -> Scripting.FileSystemObject

Not interested in workarounds.. I can make them if need be.

Re: Miscallaneous identifiers #141391
09/02/06 01:59 AM
09/02/06 01:59 AM
Joined: Apr 2004
Posts: 218
Indiana, USA
P
PhantasyX Offline
Fjord artisan
PhantasyX  Offline
Fjord artisan
P

Joined: Apr 2004
Posts: 218
Indiana, USA
I concur with the idea of them all.


Live to Dream & Dream for Life
Re: Miscallaneous identifiers #141392
09/02/06 01:08 PM
09/02/06 01:08 PM
Joined: Nov 2004
Posts: 799
I live inside your computer. S...
Jigsy Offline
Hoopy frood
Jigsy  Offline
Hoopy frood

Joined: Nov 2004
Posts: 799
I live inside your computer. S...
$reverse isn't that hard to script but I still like the ideas smile

Code:
alias reverse {
  if ($1-) {
    var %x = 0
    while (%x &lt; $len($1-)) {
      inc %x 1
      var %string = $mid($1-,%x,1) $+ %string
    }
    return %string
  }
}


This signature is currently out of order. We apologize for the inconvenience.
Re: Miscallaneous identifiers #141393
09/02/06 01:18 PM
09/02/06 01:18 PM
Joined: Feb 2004
Posts: 2,019
Leuven, Belgium
FiberOPtics Offline
Hoopy frood
FiberOPtics  Offline
Hoopy frood

Joined: Feb 2004
Posts: 2,019
Leuven, Belgium
$reverse(0) gives no output in your alias.

if (<value>) is $false if <value> is 0, $null or $false

You don't need that if check anyway, because it is already achieved through the while loop. A /while is basically an /if check which repeats the body of the while loop until the expression evaluates to $false.

Btw identifiers delimit tokens by commas, not by spaces, so inside your alias, the entire string is stored in $1, using $1- is not necessary. And it's nasty to put that $len in your while condition, with every iteration it must calculate the length of the string.

Additionally, you are only declaring the local variable %string inside the while loop, meaning if no input was given, and you had a global variable %string, it would give the value of that instead of $null. Even if you would give an input, with the very first iteration in the while loop, it would still mess things up because %string would evaluate to the value of the global %string and be appended to the local variable %string.

But anyway, I guess you didn't read hixxy's post very carefully because it states at the end:

"Not interested in workarounds.. I can make them if need be."


Gone.
Re: Miscallaneous identifiers #141394
09/02/06 02:52 PM
09/02/06 02:52 PM
Joined: Nov 2004
Posts: 799
I live inside your computer. S...
Jigsy Offline
Hoopy frood
Jigsy  Offline
Hoopy frood

Joined: Nov 2004
Posts: 799
I live inside your computer. S...
Yeah I have a problem with reading ...


Anyway ... I'd like to see a $shortscriptdir identifier so I don't have to use $shortfn($scriptdir) all the time ...


This signature is currently out of order. We apologize for the inconvenience.
Re: Miscallaneous identifiers #141395
09/02/06 08:09 PM
09/02/06 08:09 PM
Joined: Dec 2002
Posts: 2,962
Norwich, UK
S
starbucks_mafia Offline
Hoopy frood
starbucks_mafia  Offline
Hoopy frood
S

Joined: Dec 2002
Posts: 2,962
Norwich, UK
$rangetok(): Could be useful.

$reverse(): Personally I don't think of this as something which is particularly useful in a general scripting sense. Sure, a lot of people have 'reverse text' aliases/responders but I'd say it's someting to be left up to scripting. I think half the fun of a reverse-string function in any language is trying to find the best way to do it. I remember there was a big thread about making the fastest reverse identifier in the Scripting forum once before that I always found very interesting.

$blendian(): Seems like a bit of a niche use for a built-in identifier to me.

$clsid2prog(): I rarely use COM so I've got no opinion on this whatsoever.

As always, insert 'personal opinion' disclaimer here etc. etc.

Last edited by starbucks_mafia; 09/02/06 08:21 PM.
Re: Miscallaneous identifiers #141396
09/02/06 09:00 PM
09/02/06 09:00 PM
Joined: Sep 2005
Posts: 2,876
H
hixxy Offline OP
Hoopy frood
hixxy  Offline OP
Hoopy frood
H

Joined: Sep 2005
Posts: 2,876
Quote:
$blendian(): Seems like a bit of a niche use for a built-in identifier to me.


You're right, that's why I suggested the addition to $reverse in brackets. The $blendian thing was something I had to script for use in a specific algorithm for a protocol.

Re: Miscallaneous identifiers #141397
09/02/06 09:41 PM
09/02/06 09:41 PM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
DaveC  Offline
Hoopy frood
D

Joined: Sep 2003
Posts: 4,230
Im a bit confused on this...
$blendian(1234) -> 3412
$blendian(12345678) -> 78563412

I awlays thought bigendian values were the highest byte first, be it word or dword or what ever is bigger than dword (ddword?)

As in if the hex value of a number was 0x12345678 the dword value would be stored/transmitted as four bytes as follows 0x12 0x34 0x56 0x78
Unlike say x86 values which are LSB (least significant byte first) 0x78 0x56 0x34 0x12

Now in your example ignoring that the value might have been decimal, ill assume its a hex representation, doesnt that mean the out put was actually LSB ? (low endian <- i dont know if thats a real name)

Re: Miscallaneous identifiers #141398
09/02/06 09:54 PM
09/02/06 09:54 PM
Joined: Sep 2005
Posts: 2,876
H
hixxy Offline OP
Hoopy frood
hixxy  Offline OP
Hoopy frood
H

Joined: Sep 2005
Posts: 2,876
I didn't really do that much research into this, I just know that I read documentation on an algorithm and the authors said you swap bytes around.

Quote:
These hexadecimal numbers should be written in Little Endian order, this means that you should swap the bytes around in a number of languages (for example PHP and C#, but not Perl and Visual Basic) in order to have access to the values of these integers. You should also take in account the default Endian Order of the system you are working on (for example, Intel machines are LE, while Apple machines are typically using BE).


Their examples also suggest this is correct.

Quote:
0x5b301715 = 0x1517305b = 353841243
0x9e3947f8 = 0xf847399e = 2017933726
0xff981604 = 0x041698ff = 68589823

Re: Miscallaneous identifiers #141399
10/02/06 06:52 AM
10/02/06 06:52 AM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
DaveC  Offline
Hoopy frood
D

Joined: Sep 2003
Posts: 4,230
ok i see where you have come from, taking the last example (LE) 0xff981604 = (BE) 0x041698ff = (DEC) 68589823 68,589,823 is in hex 0x041698FF which is a close representation to a big endian ordered value anyway, so the only real meaning full values that you might load in $bigendian( ) is a string representing a Low Endian value in which case it would swap it around as per your specs, actually it might as well be called $endian( ) and the function would work in both directions, as 12345678 becomes 78563412 and 78563412 becomes 12345678.

Still would it be that usefull, not exactly a large number of people would ever need to convert a hex value to LE order or viseversa?

Still no reason not to have something is it smile

/me runs off yealling BigEdian BigEndian BigEndian

PS: i did think $reverse was a little silly tho!

Re: Miscallaneous identifiers #141400
10/02/06 07:19 AM
10/02/06 07:19 AM
Joined: Sep 2005
Posts: 2,876
H
hixxy Offline OP
Hoopy frood
hixxy  Offline OP
Hoopy frood
H

Joined: Sep 2005
Posts: 2,876
** from now on when I talk about reverse I'm talking about the addition suggested in the brackets to $blendian **

Quote:
Still would it be that usefull, not exactly a large number of people would ever need to convert a hex value to LE order or viseversa?


Nope. That's why I suggested the addition to $reverse in brackets as an alternative.

As for reverse being silly we already have at least one practical use for it, which is what we just talked about; endian swapping, even if this isn't a pressing task.

Re: Miscallaneous identifiers #141401
10/02/06 02:32 PM
10/02/06 02:32 PM
Joined: Apr 2004
Posts: 839
The Netherlands
Sat Offline
Hoopy frood
Sat  Offline
Hoopy frood

Joined: Apr 2004
Posts: 839
The Netherlands
Just a thought - I think a byteswapping function would be much more practically applicable if it were to take and produce decimal numbers instead of hexadecimal. This would make it compatible with $longip without having to use $base all the time. At least for me, the combination of $longip and a byteswapping function would be rather useful; however, that means it would not be natural to group it under a new $reverse identifier, as that function would work on a character level. It would also need an extra option/property to distinguish between shorts and longs.

Personally, I would have no use for a byteswapping function that takes hexadecimal values, as the workarounds for most practical uses of it would then be shorter/simpler.


Saturn, QuakeNet staff
Re: Miscallaneous identifiers #141402
13/02/06 06:48 AM
13/02/06 06:48 AM
Joined: Dec 2002
Posts: 198
Ohio, USA
T
Talon Offline
Vogon poet
Talon  Offline
Vogon poet
T

Joined: Dec 2002
Posts: 198
Ohio, USA
USELESS! $gettok(this is a test,1-2,32) = this is. why do you need a new identifier for this?

Re: Miscallaneous identifiers #141403
13/02/06 06:50 AM
13/02/06 06:50 AM
Joined: Sep 2005
Posts: 2,876
H
hixxy Offline OP
Hoopy frood
hixxy  Offline OP
Hoopy frood
H

Joined: Sep 2005
Posts: 2,876
What?! None of my suggestions are anything like that.

Re: Miscallaneous identifiers #141404
13/02/06 08:05 AM
13/02/06 08:05 AM
Joined: Dec 2002
Posts: 198
Ohio, USA
T
Talon Offline
Vogon poet
Talon  Offline
Vogon poet
T

Joined: Dec 2002
Posts: 198
Ohio, USA
sorry, i didnt read closely what it did, i thought you wanted to get a range of tokens, which mIRC already does.. I didnt realize you meant construct a range..

Re: Miscallaneous identifiers #141405
13/02/06 10:11 AM
13/02/06 10:11 AM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
DaveC  Offline
Hoopy frood
D

Joined: Sep 2003
Posts: 4,230
i would include in $rangetok

$rangetok(N1,N2,asc) - returns a range from N1 to N2 separated by asc, N1 and N2 being numbers or any non number which means a tokenized list of asc values from N1 to N2, not including the token eperator, so $rangtok(D,G,32) -> D E F G

Re: Miscallaneous identifiers #141406
13/02/06 10:45 AM
13/02/06 10:45 AM
Joined: Aug 2004
Posts: 7,252
Ontario, Canada
R
RusselB Offline
Hoopy frood
RusselB  Offline
Hoopy frood
R

Joined: Aug 2004
Posts: 7,252
Ontario, Canada
Sounds good to me, and one thing that I would like to see (if I haven't missed it..if I have, someone point it out to me), is soemthing similar to $didtok but uses the items selected in a dialog box. $did(<name>,<id>,0).sel will return the number of items selected, but if I want a list of just those items, I have to loop through them. Not bad if you don't have too many items, but if the list is lengthy, it can take a bit of time.

Re: Miscallaneous identifiers #141407
18/02/06 04:49 PM
18/02/06 04:49 PM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
Hoopy frood
qwerty  Offline
Hoopy frood
Q

Joined: Jan 2003
Posts: 2,523
Here's an even faster version than the binvar one (more than twice as fast), using $regsubex():
Code:
alias rev var %a = $1 | return $regsubex(%a,/./g,$mid(%a,-\n,1))

The variable is there because of a $regsubex() bug, when it's fixed it could be as short/simple as
Code:
return $regsubex($1,/./g,$mid($1,-\n,1))


$regsubex() has a lot of potential, with a little imagination you can even do things unrelated to pattern matching smile

Edit: FiberOPtics pointed out that the alias kills spaces... as you know $mid() does retain them, it's whatever's being done internally in $regsubex() that kills them frown I want to believe that those $regsubex() problems will be ironed out eventually though.

Last edited by qwerty; 18/02/06 05:11 PM.