Truncate a file: Difference between revisions

Added Wren
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
(Added Wren)
Line 1,308:
Call truncate("C:\temp\test.txt",30)
</lang>
 
=={{header|Wren}}==
{{libheader|Wren-ioutil}}
<lang ecmascript>import "/ioutil" for FileUtil
 
var fileName = "temp.txt"
 
// create a file of length 26 bytes
FileUtil.write(fileName, "abcdefghijklmnopqrstuvwxyz")
System.print("Contents before truncation: %(FileUtil.read(fileName))")
 
// truncate file to 13 bytes
FileUtil.truncate(fileName, 13)
System.print("Contents after truncation : %(FileUtil.read(fileName))")
 
// attempt to truncate file to 20 bytes
FileUtil.truncate(fileName, 20)
System.print("Contents are still : %(FileUtil.read(fileName))")</lang>
 
{{out}}
<pre>
Contents before truncation: abcdefghijklmnopqrstuvwxyz
Contents after truncation : abcdefghijklm
Contents are still : abcdefghijklm
</pre>
 
=={{header|ZX Spectrum Basic}}==
9,482

edits