Bcopy » History » Revision 5
Revision 4 (Per Amundsen, 02/08/2014 11:33 PM) → Revision 5/7 (Per Amundsen, 02/08/2014 11:34 PM)
_Added in 1.9.0_
*/bcopy [-zc] <&binvar> <N> <&binvar> <S> <M>*
Copies <M> bytes from position <S> in the second &binvar to the first &binvar at position <N>.
This can also be used to copy overlapping parts of a &binvar to itself.
*Switches*
-z - The bytes in the second &binvar that is copied are zero-filled after the copy.
-c - The first &binvar is chopped to <N> + <M>.
*Parameters*
<&binvar> - Target &binvar to copy to.
<N> - Target position in the first &binvar to copy to.
<&binvar> - Source &binvar to copy from.
<S> - Source position to copy from.
<M> - Number of bytes to copy.
*Example*
<pre>
alias /example {
;Create a binary variable and assign it some text
bset -t &example 1 This is a test!
;Copy from 'example' from the 11th byte 10 bytes onward
;Zero-fill the part that was copied
bcopy -z &example2 1 &example 11 10
;Print out &example's content (up to the first null)
echo -a $bvar(&example, 1-).text
;Print out &example2's content
echo -a $bvar(&example2, 1-).text
}
</pre>