/****************************************************************************** * This program simply writes characters from the alphabet to a file. * * Copyright © 2020 Richard Lesh. All rights reserved. *****************************************************************************/ mod utils; use std::error; use std::sync::Arc; fn writeTextFile(filespec:&str) -> Result<(), Arc> { utf8mode(ofh); // Latin alphabet { let mut c:i32 = 0x41; while c <= 0x5A { putcodepoint(c,ofh); c += 1; } } putchar('\n',ofh); // Greek alphabet { let mut c:i32 = 0x391; while c <= 0x3A9 { putcodepoint(c,ofh); c += 1; } } // Cyrillic alphabet { let mut c:i32 = 0x410; while c <= 0x42F { putcodepoint(c,ofh); c += 1; } } putchar('\n',ofh); // Katakana alphabet { let mut c:i32 = 0x30A0; while c <= 0x30FF { putcodepoint(c,ofh); c += 1; } } putchar('\n',ofh); close(ofh)?; } fn main() { if args.len() != 2 { println!("Syntax: {} {{filename}}", utils::program_name().expect("program name should not be empty!")); exit(1); } let mut filespec:String = args[1]; match (|| -> Result<(), Arc>{ writeTextFile(&filespec)?; return Ok(()); })() { Ok(()) => {}, Err(ex) => { if let Some(ex) = utils::isCustomErrorType(ex.clone(), io::Error("".to_string())){ println!("Error: {}", format!("{}", ex)); } } }; }