File input/output: Difference between revisions

m
Add another lang example
m (Add libheader to the lang example)
m (Add another lang example)
Line 2,559:
 
=={{header|Lang}}==
===Text-based===
{{libheader|lang-io-module}}
<syntaxhighlight lang="lang">
Line 2,570 ⟶ 2,571:
$text = [[io]]::fp.readFile($fileIn)
[[io]]::fp.writeFile($fileOut, $text)
 
[[io]]::fp.closeFile($fileIn)
[[io]]::fp.closeFile($fileOut)
</syntaxhighlight>
 
===Byte-based===
{{libheader|lang-io-module}}
<syntaxhighlight lang="lang">
# Load the IO module
# Replace "<pathToIO.lm>" with the location where the io.lm lang module was installed to without "<" and ">"
ln.loadModule(<pathToIO.lm>)
 
$fileIn = [[io]]::fp.openFile(input.txt)
$fileOut = [[io]]::fp.openFile(output.txt)
 
$bytes = [[io]]::fp.readBytes($fileIn)
[[io]]::fp.writeBytes($fileOut, $bytes)
 
[[io]]::fp.closeFile($fileIn)
168

edits