> do read=0 to %@filesize[%1,b]
> if %_kbhit == 1 leave
> set _bit=%@be64[%@fileread[%open_0,1]]
> if %_bit == 00 set _bit=%@format[08,0]
> set write=%@filewriteb[%open_2,8,%_bit]
> enddo
If you get rid of your be64 function and replace your loop with the
following, I think the program will work.
There are much more efficient means, but I think this is the smallest
perturbation to your algorithm.
do read=0 to %@filesize[%1,b]
if %_kbhit == 1 leave
set _bit=%@format[08,%@convert[10,2,%@filereadb[%open_0,1]]]
set write=%@filewriteb[%open_2,8,%_bit]
enddo
To make the program much more efficient, instead of converting to
binary and back to BASE64, you could construct a number with something
like the following. Note that I just typed this into the email without
actually trying it. You'll need to test for EOF in the filereadb.
set number=%@filereadb[%open_0,1]
set number=%@eval[(number SHL 8) + %@filereadb[%open_0,1]]
set number=%@eval[(number SHL 8) + %@filereadb[%open_0,1]]
Then deconstruct the three bytes (24 bits) into the four 6-bit chunks with
set sixbit=%@eval[(%number SHR 18) AND 0x3F]
set wrote=%@filewriteb[%open_1,1,%sixbit]
set sixbit=%@eval[(%number SHR 12) AND 0x3F]
set wrote=%@filewriteb[%open_1,1,%sixbit]
set sixbit=%@eval[(%number SHR 6) AND 0x3F]
set wrote=%@filewriteb[%open_1,1,%sixbit]
set sixbit=%@eval[(%number SHR 0) AND 0x3F]
set wrote=%@filewriteb[%open_1,1,%sixbit]
--
2008 Fridays: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
Next year they're Saturday.
Measure wealth by the things you have for which you would not take money.