Project

General

Profile

Bcopy » History » Version 2

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 2 Per Amundsen
<pre>
22 1 Per Amundsen
alias /example {
23
  ;Create a binary variable and assign it some text
24
  bset -t &example 1 This is a test!
25
 
26
  ;Copy from 'example' from the 11th byte 10 bytes onward
27
  ;Zero-fill the part that was copied
28
  bcopy -z &example2 1 &example 11 10
29
 
30
  ;Print out &example's content (up to the first null)
31
  echo -a $bvar(&example, 1-).text
32
 
33
  ;Print out &example2's content
34
  echo -a $bvar(&example2, 1-).text 
35
}
36 2 Per Amundsen
</pre>