File input/output: Difference between revisions
Content added Content deleted
m (Add libheader to the lang example) |
m (Add another lang example) |
||
Line 2,559: | Line 2,559: | ||
=={{header|Lang}}== |
=={{header|Lang}}== |
||
===Text-based=== |
|||
{{libheader|lang-io-module}} |
{{libheader|lang-io-module}} |
||
<syntaxhighlight lang="lang"> |
<syntaxhighlight lang="lang"> |
||
Line 2,570: | Line 2,571: | ||
$text = [[io]]::fp.readFile($fileIn) |
$text = [[io]]::fp.readFile($fileIn) |
||
[[io]]::fp.writeFile($fileOut, $text) |
[[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) |
[[io]]::fp.closeFile($fileIn) |