#!/usr/bin/env swift; /****************************************************************************** * This program simply writes lines with the alphabet to a file. * * Copyright © 2020 Richard Lesh. All rights reserved. *****************************************************************************/ import Foundation import Utils func writeTextFile(_ filespec:String) throws -> Void { FileManager.default.createFile(atPath: filespec, contents: nil) let ofh:FileHandle? = FileHandle(forWritingAtPath: filespec) if ofh == nil { throw RuntimeError("Problem opening output file!") } ofh!.write("ABCDEFGHIJKLMNOPQRSTUVWXYZ".data(using: .utf8)!);ofh!.write("\n".data(using: .utf8)!) ofh!.write("ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ".data(using: .utf8)!);ofh!.write("\n".data(using: .utf8)!) ofh!.write("АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ".data(using: .utf8)!);ofh!.write("\n".data(using: .utf8)!) ofh!.write("゠ァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタ".data(using: .utf8)!);ofh!.write("\n".data(using: .utf8)!) ofh!.write("ダチヂッツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミ".data(using: .utf8)!);ofh!.write("\n".data(using: .utf8)!) ofh!.write("ムメモャヤュユョヨラリルレロヮワヰヱヲンヴヵヶヷヸヹヺ・ーヽヾヿ".data(using: .utf8)!);ofh!.write("\n".data(using: .utf8)!) try ofh!.close() } // Begin Main if CommandLine.arguments.count != 2 { print("Syntax: " + CommandLine.arguments[0] + " {filename}") exit(1) } var filespec:String = CommandLine.arguments[1] do { try writeTextFile(filespec) } catch let ex as RuntimeError { print("Error: " + ex.localizedDescription) } exit(EXIT_SUCCESS)