Project

General

Profile

Bcopy » History » Version 1

Per Amundsen, 02/08/2014 10:26 PM

1 1 Per Amundsen
*/bcopy [-zc] <&binvar> <N> <&binvar> <S> <M>*
2
3
Copies <M> bytes from position <S> in the second &binvar to the first &binvar at position <N>.
4
This can also be used to copy overlapping parts of a &binvar to itself.
5
6
*Switches*
7
8
-z - The bytes in the second &binvar that is copied are zero-filled after the copy.
9
-c - The first &binvar is chopped to <N> + <M>.
10
11
*Parameters*
12
13
<&binvar> - Target &binvar to copy to.
14
<N> - Target position in the first &binvar to copy to.
15
<&binvar> - Source &binvar to copy from.
16
<S> - Source position to copy from.
17
<M> - Number of bytes to copy.
18
19
*Example*
20
21
alias /example {
22
  ;Create a binary variable and assign it some text
23
  bset -t &example 1 This is a test!
24
 
25
  ;Copy from 'example' from the 11th byte 10 bytes onward
26
  ;Zero-fill the part that was copied
27
  bcopy -z &example2 1 &example 11 10
28
 
29
  ;Print out &example's content (up to the first null)
30
  echo -a $bvar(&example, 1-).text
31
 
32
  ;Print out &example2's content
33
  echo -a $bvar(&example2, 1-).text 
34
}