Project

General

Profile

Actions

Feature #5520

closed

/bset suggestion for 16bits + 32bits numbers

Added by westor (GR) 8 months ago. Updated 8 months ago.

Status:
Rejected
Priority:
Normal
Assignee:
Category:
Scripting
Target version:
Start date:
04/03/2022
Due date:
% Done:

0%

Estimated time:
Operative System:
All

Description

Hello,

If its possible for AdiIRC to having some new switches that will treat a value above 255 as 16bits or 32bits number for little/big endian, this is going to help a lot as AdiIRC already having some extra properties for reading.

Description :

-w = word, 16 bits little endian
-nw = word, 16 bits big endian
-l = word, 32 bits little endian
-nl = word, 32 bits big endian

OR

-l16 -l32 = word, 16 or 32 bits little endian
-b16 -b32 = word, 16 or 32 bits big endian

Examples :

//bset -w &a -1 256 | echo -ag $bvar(&a,1-) should produce 0 1
//bset -nw &a -1 256 | echo -ag $bvar(&a,1-) should produce 1 0
//bset -l &a -1 256 | echo -ag $bvar(&a,1-) should produce 0 1 0 0
//bset -nl &a -1 256 | echo -ag $bvar(&a,1-) should produce 0 0 1 0

- Thanks!

Actions #1

Updated by Per Amundsen 8 months ago

  • Status changed from New to Rejected

$bvar() already has ".word" ".nword" properties etc.

Actions #2

Updated by westor (GR) 8 months ago

Sorry but i think you confused here, i suggesting something for /bset not $bvar() , or please explain me what you meant to use $bvar() ? i don't see that makes sense or maybe i miss something here.

- Thanks!

Actions #3

Updated by Sean Everett 8 months ago

what westor is after is the ability to work in bit ranges. to say: Everything I'm passing is 16bit or 32bit. The end goal is to have a proper binary variable representation still in the native 8bit. (The ability to ADD/INSERT/APPEND a word/nword/long/nlong rather than have to convert it into high/low bits)

So like /bset <&var> <N> <value> [value value]
N represents the position, value is a range of 0-255

if we used a flag for 16bit, now "value" is of range 0-65535.
if we used a flag for 32bit, now "value" is of range 0-4294967295.

if we were to translate this from 16bit, we'd need the high/low (split 16bit into two 8bit values) also N would need to reflect this as well, so if N was 2, now we gotta think it's 8bit, so the "position" would be 3 (because our 1st 16bit value is position 1-2, our 2nd 16bit position would be 3-4, etc...) If 32bit, everything doubles, now we need 4 8bit values to represent "value", and 4 positions to store these values...

N can have negative values, -1,-2,-3 etc.. these too need translated to positions in 8bit, this just specifies insert this data N values from the end.

here's a scripted version of the requested functionality:

Nbset {
  if ($1 == -w || $1 == -l16) { var %bits = 16 }
  elseif ($1 == -nw || $1 == -b16) { var %bits = -16 }
  elseif ($1 == -l || $1 == -l32) { var %bits = 32 }
  elseif ($1 == -nl || $1 == -b32) { var %bits = -32 }
  if (%bits) {
    if ($abs(%bits) == 16) {
      if (%bits < 0) { bset $2 $iif($3 < 0,$max(1,$calc($bvar($2,0) + $3 * 2 + 1)),$calc(($3 - 1) * 2 + 1)) $regsubex($4-,/(\d+)/g,$calc(\t // 256) $calc(\t % 256)) }
      else { bset $2 $iif($3 < 0,$max(1,$calc($bvar($2,0) + $3 * 2 + 1)),$calc(($3 - 1) * 2 + 1)) $regsubex($4-,/(\d+)/g,$calc(\t % 256) $calc(\t // 256)) }
    }
    elseif ($abs(%bits) == 32) {
      if (%bits < 0) { bset $2 $iif($3 < 0,$max(1,$calc($bvar($2,0) + $3 * 4 + 1)),$calc(($3 - 1) * 4 + 1)) $regsubex($4-,/(\d+)/g,$calc($and(\t,4278190080) / 16777216) $calc($and(\t,16711680) / 65536) $calc($and(\t,65280) / 256) $and(\t,255)) }
      else { bset $2 $iif($3 < 0,$max(1,$calc($bvar($2,0) + $3 * 4 + 1)),$calc(($3 - 1) * 4 + 1)) $regsubex($4-,/(\d+)/g,$and(\t,255) $calc($and(\t,65280) / 256) $calc($and(\t,16711680) / 65536) $calc($and(\t,4278190080) / 16777216)) }
    }
  }
  else { bset $1- }
}

//nbset -w &a -1 256 | echo -a $bvar(&a,1-) is: $bvar(&a,1).word
0 1 is: 256
//nbset -nw &a -1 256 | echo -a $bvar(&a,1-) is: $bvar(&a,1).nword
1 0 is: 256
//nbset -l &a -1 256 | echo -a $bvar(&a,1-) is: $bvar(&a,1).long
0 1 0 0 is: 256
//nbset -nl &a -1 256 | echo -a $bvar(&a,1-) is: $bvar(&a,1).nlong
0 0 1 0 is: 256
Actions #4

Updated by Oui Ouims 8 months ago

Mistakes can be made, but more than a week has passed, this suggestions was completely misread by you kr0n and rejected with completely invalid reasons, it has nothing to do with $bvar, can this suggestion's status be changed back to open??

Actions

Also available in: Atom PDF