Rename a file: Difference between revisions

Add lang example
(→‎min: add)
(Add lang example)
Line 674:
c:\docs successfully renamed to c:\mydocs
</pre>
 
=={{header|Lang}}==
Currently this task is only possible by using Standard Lang and the 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>)
 
fp.rename = ($from, $to) -> {
$fileFrom = [[io]]::fp.openFile($from)
$fileTo = [[io]]::fp.openFile($to)
[[io]]::fp.rename($fileFrom, $fileTo)
[[io]]::fp.closeFile($fileFrom)
[[io]]::fp.closeFile($fileTo)
}
 
fp.rename(input.txt, output.txt)
fp.rename(/input.txt, /output.txt)
fp.rename(docs, mydocs)
fp.rename(/docs, /mydocs)
</syntaxhighlight>
 
=={{header|Lasso}}==
168

edits