Create a file on magnetic tape: Difference between revisions
m
syntax highlighting fixup automation
No edit summary |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 21:
=={{header|Action!}}==
<
BYTE dev=[1]
Line 58:
PrintE("Rewind the tape and press any key to load previously saved file from tape.")
Load()
RETURN</
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Create_a_file_on_magnetic_tape.png Screenshot from Atari 8-bit computer]
Line 74:
=={{header|Applesoft BASIC}}==
<syntaxhighlight lang
=={{header|Arturo}}==
<
This code
should be able to write
a file
to magnetic tape
}</
=={{header|C}}==
The program is self explanatory. :)
<syntaxhighlight lang="c">
#include<stdio.h>
Line 108:
}
</syntaxhighlight>
=={{header|C++}}==
{{trans|D}}
<
#include <fstream>
Line 128:
fb.close();
return 0;
}</
=={{header|Clojure}}==
<
=={{header|COBOL}}==
Line 137:
{{works with|OpenCOBOL}}
<
IDENTIFICATION DIVISION.
PROGRAM-ID. MAKE-TAPE-FILE.
Line 158:
FROM "COBOL treats tape files and text files identically."
END-WRITE
STOP RUN.</
=={{header|Crystal}}==
{{trans|D}}
<
"TAPE.FILE"
{% else %}
"/dev/tape"
{% end %}
File.write filename, "howdy, planet!"</
=={{header|D}}==
<
void main() {
Line 179:
}
f.writeln("Hello World!");
}</
=={{header|Delphi}}==
{{Trans|D}}
<syntaxhighlight lang="delphi">
program Create_a_file_on_magnetic_tape;
Line 204:
close(f);
end.
</syntaxhighlight>
=={{header|F#}}==
<
open System
open System.IO
Line 217:
| PlatformID.Win32NT | PlatformID.Win32S | PlatformID.Win32Windows | PlatformID.WinCE -> File.WriteAllText("TAPE.FILE", msg)
| _ -> File.WriteAllText("/dev/tape", msg)
</syntaxhighlight>
=={{header|Factor}}==
<
"Hello from Rosetta Code!"
os windows? "tape.file" "/dev/tape" ?
ascii set-file-contents</
=={{header|Fortran}}==
Line 237:
=={{header|FreeBASIC}}==
<
Open "tape.file" For Output As #numarch
Print #numarch, "Soy un archivo de cinta ahora, o espero serlo pronto."
Close #numarch</
=={{header|Go}}==
Line 249:
The tar archive will contain a single file, called <tt>TAPE.FILE</tt> by default,
with the contents of the command line <tt>-data</tt> option.
<
import (
Line 301:
log.Fatal("writing data:", err)
}
}</
{{out}}
<pre>
Line 309:
=={{header|Groovy}}==
{{trans|Java}}
<
import java.nio.file.Path
import java.nio.file.Paths
Line 324:
}
}
}</
=={{header|Haskell}}==
<
main :: IO ()
main = writeFile "/dev/tape" "Hello from Rosetta Code!"</
=={{header|Icon}} and {{header|Unicon}}==
This solution mimics the solution used in many other languages here and works in both Icon and Unicon.
<
write(open("/dev/tape","w"),"Hi")
end</
=={{header|IS-BASIC}}==
<
110 PRINT #1:"I am a tape file now, or hope to be soon."
120 CLOSE #1</
=={{header|Java}}==
<
import java.nio.file.Files;
import java.nio.file.Path;
Line 363:
}
}
}</
=={{header|JCL}}==
<
//* Create a file named "TAPE.FILE" on magnetic tape; "UNIT=TAPE"
//* may vary depending on site-specific esoteric name assignment
Line 374:
//SYSUT1 DD *
DATA TO BE WRITTEN TO TAPE
/* </
=={{header|Julia}}==
<
open("/dev/tape", "w") do f
write(f, "Hello tape!")
end
</syntaxhighlight>
=={{header|Kotlin}}==
{{trans|Scala}}
<
import java.io.FileWriter
Line 393:
lp0.write("Hello, world!")
lp0.close()
}</
=={{header|Lua}}==
<
local out
Line 406:
file = io.open(out, 'w')
file:write('Hello world')
io.close(file)</
=={{header|Nim}}==
<
t.writeln "Hi Tape!"
t.close</
=={{header|Phix}}==
<
constant filepath = iff(platform()=WINDOWS?"tape.file":"/dev/tape"),
write_file(file_path,"Hello world!")</
=={{header|PicoLisp}}==
<
(prin "Hello World!") )</
=={{header|Python}}==
<
...
>>> </
=={{header|Racket}}==
<syntaxhighlight lang="racket">
#lang racket
(with-output-to-file "/dev/tape" #:exists 'append
(λ() (displayln "I am a cheap imitation of the Perl code for a boring problem")))
</syntaxhighlight>
=={{header|Raku}}==
(formerly Perl 6)
<syntaxhighlight lang="raku"
$tape.say: "I am a tape file now, or hope to be soon.";
$tape.close;</
=={{header|REXX}}==
Line 446:
<br><br>VM/CMS would use a '''CP ATTACH''' command, coupled with a '''CMS FILEDEF''' command which associates a
<br>DSNAME (dataset name) that will be written to on the attached (and mounted) magnetic tape device.
<
dsName = 'TAPE.FILE' /*dsName of "file" being written.*/
Line 452:
call lineout dsName, 'this is record' j || "."
end /*j*/
/*stick a fork in it, we're done.*/</
=={{header|Ring}}==
<
# Project : Create a file on magnetic tape
Line 463:
fwrite(fp, str)
fclose(fp)
</syntaxhighlight>
=={{header|Ruby}}==
{{trans|C}}
<
fh.syswrite("This code should be able to write a file to magnetic tape.\n")
end</
=={{header|Rust}}==
<
use std::fs::File;
fn main() -> std::io::Result<()> {
File::open("/dev/tape")?.write_all(b"Hello from Rosetta Code!")
}</
=={{header|Scala}}==
===[[Unix]]===
Assuming device is attached to "tape"
<
import java.io.{ FileWriter, IOException }
{
Line 489:
lp0.close()
}
}</
=={{header|Seed7}}==
<
const proc: main is func
Line 509:
writeln(" ***** Cannot open tape file.");
end if;
end func;</
=={{header|Tcl}}==
Tcl does not have built-in special support for tape devices, so it relies on the OS to handle most of the details for it. Assuming a relatively modern Unix:
{{trans|UNIX Shell}}
<
# Create the file
Line 526:
fcopy $fin $fout
close $fin
close $fout</
=={{header|TUSCRIPT}}==
<
STATUS = CREATE ("tape.file",tape-o,-std-)
PRINT STATUS</
{{Out}}
<pre>
Line 538:
=={{header|UNIX Shell}}==
<
cd # Make our home directory current
echo "Hello World!" > hello.jnk # Create a junk file
# tape rewind # Uncomment this to rewind the tape
tar c hello.jnk # Traditional archivers use magnetic tape by default
# tar c hello.jnk > /dev/tape # With newer archivers redirection is needed</
=={{header|Wren}}==
<
import "io" for File
Line 552:
File.create(fileName) { |file|
file.writeBytes("Hello World!\n")
}</
=={{header|ZX Spectrum Basic}}==
Line 559:
We can use any start address, depending on where we want the data to come from.
Here we dump the contents of the screen:
<
|