mIRC Home    About    Download    Register    News    Help

Print Thread
#52095 01/10/03 09:06 AM
Joined: Jun 2003
Posts: 77
O
ozyvent Offline OP
Babel fish
OP Offline
Babel fish
O
Joined: Jun 2003
Posts: 77
Could someone please tell me how I can split this: 11001010000001111010101100010111
into 4 equal sets of 8 numbers with each set in these variables %ip.1, %ip.2, %ip.3 and %ip.4

Thanks



.
#52096 01/10/03 10:41 AM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
You need to look into $mid() (/help $mid)
Code:
  var %a = 11001010000001111010101100010111
  %ip.1 = $mid(%a,1,8)
  %ip.2 = $mid(%a,9,8)
  %ip.3 = $mid(%a,17,8)
  %ip.4 = $mid(%a,25)



/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#52097 01/10/03 12:06 PM
Joined: Jun 2003
Posts: 77
O
ozyvent Offline OP
Babel fish
OP Offline
Babel fish
O
Joined: Jun 2003
Posts: 77
Thanks cool cool


.
#52098 01/10/03 02:52 PM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
Code:
; seperates a long string of bytes into their individual byte sections.
; Param: byteString[, unsettime]
; - byteString - Contains the string of bytes grouped together (ex: 0101101010100101)
; - unsetTime  - (optional) unsets the %octet variables after the specified time in seconds
/octets {
  var %pos = 1
  /unset %octet.*
  while ($mid($$1, %pos, 8)) {
    /set $iif($2, $+(-u,$2)) %octet. [ $+ [ $floor($calc(%pos / 8)) ] ] $mid($$1, %pos, 8)
    /inc %pos 8
  }
  return $floor($calc(%pos / 8))
}


$octet(010101010101010101010101)
Will return 3 (for number of bytes) along with set the following variables:
%octet.1 01010101
%octet.2 01010101
%octet.3 01010101

EDIT: updated with comments and added unset option
EDIT: qwerty's error he pointed out (ty qwerty) >:D


-KingTomato
#52099 01/10/03 03:03 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
This won't work because $ifmatch is reset by $iif() so it doesn't hold $mid($1,%pos,8) anymore.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#52100 01/10/03 03:04 PM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
erm, ur right-- i forgot about that >:D
lemme fix >:D


-KingTomato
#52101 01/10/03 05:34 PM
Joined: May 2003
Posts: 2,265
P
Hoopy frood
Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
TEST
CODE
BEFORE
POSTING
!
>:D


new username: tidy_trax
#52102 01/10/03 05:47 PM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
For your information I did. As i stated, i edited a portion and thus it stopped working. Even stil, I EDITED the post i made wiht the code, not make 4 new posts containing the same code with 1 or two modificatons.


-KingTomato
#52103 01/10/03 05:55 PM
Joined: May 2003
Posts: 2,265
P
Hoopy frood
Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
if you make 4 new posts, or just 1 post and edit 4 times, the person your helping/trying to help still has to add the new code.
doesnt matter either way...


new username: tidy_trax

Link Copied to Clipboard