Project

General

Profile

Btrunc » History » Version 6

Per Amundsen, 02/15/2023 11:09 AM

1 1 Per Amundsen
_Added in 1.9.0_
2
3
*/btrunc <filename> <bytes>*
4
5
Truncates/extends a file to the specified length.
6
7
*Parameters*
8
9 6 Per Amundsen
table(ktable).
10
|*Parameter*|*Description*|
11
| <filename> | The file to truncate. |
12
| <bytes> | Number of bytes to truncate/extend to. |
13 1 Per Amundsen
14
*Example*
15
16 2 Per Amundsen
<pre>
17 1 Per Amundsen
alias example {
18 4 Per Amundsen
  ;Create variable %temp and add some data.
19
  /var %temp = Hello! World
20
21
  ;Write to variable %temp's content.
22
  /bwrite Example 0 $len(%temp) %temp
23
24
  ;Truncate the file down to 6 bytes.
25
  /btrunc Example 6
26
27
  ;Read the file into a variable.
28
  /bread Example 0 $file(Example).size &Example
29
30
  ;Print out the variable's content.
31
  /echo -a $bvar(&Example,1,$bvar(&Example,0)).text
32
33
  ;Delete the file.
34 5 Per Amundsen
  /remove Example
35 1 Per Amundsen
}
36 2 Per Amundsen
</pre>