|
|
Joined: Jun 2003
Posts: 77
Babel fish
|
OP
Babel fish
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
.
|
|
|
|
Joined: Jan 2003
Posts: 2,523
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 2,523 |
You need to look into $mid() (/help $mid) 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
|
|
|
|
Joined: Jun 2003
Posts: 77
Babel fish
|
OP
Babel fish
Joined: Jun 2003
Posts: 77 |
Thanks
.
|
|
|
|
Joined: Jan 2003
Posts: 3,012
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 3,012 |
; 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
|
|
|
|
Joined: Jan 2003
Posts: 2,523
Hoopy frood
|
Hoopy frood
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
|
|
|
|
Joined: Jan 2003
Posts: 3,012
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 3,012 |
erm, ur right-- i forgot about that >:D lemme fix >:D
-KingTomato
|
|
|
|
Joined: May 2003
Posts: 2,265
Hoopy frood
|
Hoopy frood
Joined: May 2003
Posts: 2,265 |
TEST CODE BEFORE POSTING ! >:D
new username: tidy_trax
|
|
|
|
Joined: Jan 2003
Posts: 3,012
Hoopy frood
|
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
|
|
|
|
Joined: May 2003
Posts: 2,265
Hoopy frood
|
Hoopy frood
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
|
|
|
|
|
|