Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
26
Task/Bitwise-IO/REXX/bitwise-io-1.rexx
Normal file
26
Task/Bitwise-IO/REXX/bitwise-io-1.rexx
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/* REXX ****************************************************************
|
||||
* 01.11.2012 Walter Pachl
|
||||
***********************************************************************/
|
||||
s='STRING' /* Test input */
|
||||
Say 's='s
|
||||
ol='' /* initialize target */
|
||||
Do While s<>'' /* loop through input */
|
||||
Parse Var s c +1 s /* pick a character */
|
||||
cx=c2x(c) /* convert to hex */
|
||||
cb=x2b(cx) /* convert to bits */
|
||||
ol=ol||substr(cb,2) /* append to target */
|
||||
End
|
||||
l=length(ol) /* current length */
|
||||
lm=l//8
|
||||
ol=ol||copies('0',8-lm) /* pad to multiple of 8 */
|
||||
pd=copies(' ',l)||copies('0',8-lm)
|
||||
Say 'b='ol /* show target */
|
||||
Say ' 'pd 'padding'
|
||||
r='' /* initialize result */
|
||||
Do While length(ol)>6 /* loop through target */
|
||||
Parse Var ol b +7 ol /* pick 7 bits */
|
||||
b='0'||b /* add a leading '0' */
|
||||
x=b2x(b) /* convert to hex */
|
||||
r=r||x2c(x) /* convert to character */
|
||||
End /* and append to result */
|
||||
Say 'r='r /* show result */
|
||||
14
Task/Bitwise-IO/REXX/bitwise-io-2.rexx
Normal file
14
Task/Bitwise-IO/REXX/bitwise-io-2.rexx
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
/*REXX pgm encodes/decodes/displays ASCII character strings as (7─bits) binary string.*/
|
||||
parse arg $; if $=='' then $= 'STRING' /*get optional argument; Use default ? */
|
||||
say ' input string=' $ /*display the input string to terminal.*/
|
||||
out= comp($); say ' encoded string=' out /*encode─► 7─bit binary string; display*/
|
||||
ori= dcomp(out); say ' decoded string=' ori /*decode─► 8─bit char " ; " */
|
||||
exit /*stick a fork in it, we're all done. */
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
comp: parse arg x; z=; do j=1 for length(x) /*convert─►right-justified 7-bit binary*/
|
||||
z= z || right( x2b( c2x( substr(x, j, 1) )), 7)
|
||||
end /*j*/; L= length(z); return left(z, L+(8-L//8)//8, 0)
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
dcomp: parse arg x; z=; do k=1 by 7 to length(x); _= substr(x, k, 7)
|
||||
if right(_, 1)==' ' then leave; z= z || x2c( b2x(0 || _) )
|
||||
end /*k*/; return z
|
||||
Loading…
Add table
Add a link
Reference in a new issue