PowerShell/Scripts/write-braille.ps1

367 lines
6.0 KiB
PowerShell
Raw Normal View History

2021-09-27 10:38:12 +02:00
<#
2021-07-13 21:10:02 +02:00
.SYNOPSIS
2021-10-04 21:29:23 +02:00
Writes text in Braille
2021-07-13 21:10:02 +02:00
.DESCRIPTION
2022-01-30 10:49:30 +01:00
This PowerShell script writes text in Braille.
2021-10-16 16:50:10 +02:00
.PARAMETER text
Specifies the text to write
2021-07-13 21:10:02 +02:00
.EXAMPLE
2021-09-25 19:43:22 +02:00
PS> ./write-braille "Hello World"
2021-08-29 17:50:03 +02:00
.NOTES
2022-01-30 10:49:30 +01:00
Author: Markus Fleschutz / License: CC0
2021-07-13 21:10:02 +02:00
.LINK
https://github.com/fleschutz/PowerShell
2020-12-29 15:14:21 +01:00
#>
2020-12-22 09:24:30 +01:00
2021-09-25 19:43:22 +02:00
param([string]$text = "")
2020-12-22 09:24:30 +01:00
2021-01-27 15:12:17 +01:00
function BrailleA { param([int]$Row)
2020-12-22 09:24:30 +01:00
switch($Row) {
1 { return ".o" }
2 { return "oo" }
3 { return "oo" }
}
}
2021-01-27 15:12:17 +01:00
function BrailleB { param([int]$Row)
2020-12-22 09:24:30 +01:00
switch($Row) {
1 { return ".o" }
2 { return ".o" }
3 { return "oo" }
}
}
2021-01-27 15:12:17 +01:00
function BrailleC { param([int]$Row)
2020-12-22 09:24:30 +01:00
switch($Row) {
1 { return ".." }
2 { return "oo" }
3 { return "oo" }
}
}
2021-01-27 15:12:17 +01:00
function BrailleD { param([int]$Row)
2020-12-22 09:24:30 +01:00
switch($Row) {
1 { return ".." }
2 { return "o." }
3 { return "oo" }
}
}
2021-01-27 15:12:17 +01:00
function BrailleE { param([int]$Row)
2020-12-22 09:24:30 +01:00
switch($Row) {
1 { return ".o" }
2 { return "o." }
3 { return "oo" }
}
}
2021-01-27 15:12:17 +01:00
function BrailleF { param([int]$Row)
2020-12-22 09:24:30 +01:00
switch($Row) {
1 { return ".." }
2 { return ".o" }
3 { return "oo" }
}
}
2021-01-27 15:12:17 +01:00
function BrailleG { param([int]$Row)
2020-12-22 09:24:30 +01:00
switch($Row) {
1 { return ".." }
2 { return ".." }
3 { return "oo" }
}
}
2021-01-27 15:12:17 +01:00
function BrailleH { param([int]$Row)
2020-12-22 09:24:30 +01:00
switch($Row) {
1 { return ".o" }
2 { return ".." }
3 { return "oo" }
}
}
2021-01-27 15:12:17 +01:00
function BrailleI { param([int]$Row)
2020-12-22 09:24:30 +01:00
switch($Row) {
1 { return "o." }
2 { return ".o" }
3 { return "oo" }
}
}
2021-01-27 15:12:17 +01:00
function BrailleJ { param([int]$Row)
2020-12-22 09:24:30 +01:00
switch($Row) {
1 { return "o." }
2 { return ".." }
3 { return "oo" }
}
}
2021-01-27 15:12:17 +01:00
function BrailleK { param([int]$Row)
2020-12-22 09:24:30 +01:00
switch($Row) {
1 { return ".o" }
2 { return "oo" }
3 { return ".o" }
}
}
2021-01-27 15:12:17 +01:00
function BrailleL { param([int]$Row)
2020-12-22 09:24:30 +01:00
switch($Row) {
1 { return ".o" }
2 { return ".o" }
3 { return ".o" }
}
}
2021-01-27 15:12:17 +01:00
function BrailleM { param([int]$Row)
2020-12-22 09:24:30 +01:00
switch($Row) {
1 { return ".." }
2 { return "oo" }
3 { return ".o" }
}
}
2021-01-27 15:12:17 +01:00
function BrailleN { param([int]$Row)
2020-12-22 09:24:30 +01:00
switch($Row) {
1 { return ".." }
2 { return "o." }
3 { return ".o" }
}
}
2021-01-27 15:12:17 +01:00
function BrailleO { param([int]$Row)
2020-12-22 09:24:30 +01:00
switch($Row) {
1 { return ".o" }
2 { return "o." }
3 { return ".o" }
}
}
2021-01-27 15:12:17 +01:00
function BrailleP { param([int]$Row)
2020-12-22 09:24:30 +01:00
switch($Row) {
1 { return ".." }
2 { return ".o" }
3 { return ".o" }
}
}
2021-01-27 15:12:17 +01:00
function BrailleQ { param([int]$Row)
2020-12-22 09:24:30 +01:00
switch($Row) {
1 { return ".." }
2 { return ".." }
3 { return ".o" }
}
}
2021-01-27 15:12:17 +01:00
function BrailleR { param([int]$Row)
2020-12-22 09:24:30 +01:00
switch($Row) {
1 { return ".o" }
2 { return ".." }
3 { return ".o" }
}
}
2021-01-27 15:12:17 +01:00
function BrailleS { param([int]$Row)
2020-12-22 09:24:30 +01:00
switch($Row) {
1 { return "o." }
2 { return ".o" }
3 { return ".o" }
}
}
2021-01-27 15:12:17 +01:00
function BrailleT { param([int]$Row)
2020-12-22 09:24:30 +01:00
switch($Row) {
1 { return "o." }
2 { return ".." }
3 { return ".o" }
}
}
2021-01-27 15:12:17 +01:00
function BrailleU { param([int]$Row)
2020-12-22 09:24:30 +01:00
switch($Row) {
1 { return ".o" }
2 { return "oo" }
3 { return ".." }
}
}
2021-01-27 15:12:17 +01:00
function BrailleV { param([int]$Row)
2020-12-22 09:24:30 +01:00
switch($Row) {
1 { return ".o" }
2 { return ".o" }
3 { return ".." }
}
}
2021-01-27 15:12:17 +01:00
function BrailleW { param([int]$Row)
2020-12-22 09:24:30 +01:00
switch($Row) {
1 { return "o." }
2 { return ".." }
3 { return "o." }
}
}
2021-01-27 15:12:17 +01:00
function BrailleX { param([int]$Row)
2020-12-22 09:24:30 +01:00
switch($Row) {
1 { return ".." }
2 { return "oo" }
3 { return ".." }
}
}
2021-01-27 15:12:17 +01:00
function BrailleY { param([int]$Row)
2020-12-22 09:24:30 +01:00
switch($Row) {
1 { return ".." }
2 { return "o." }
3 { return ".." }
}
}
2021-01-27 15:12:17 +01:00
function BrailleZ { param([int]$Row)
2020-12-22 09:24:30 +01:00
switch($Row) {
1 { return ".o" }
2 { return "o." }
3 { return ".." }
}
}
2021-01-27 15:12:17 +01:00
function Braille1 { param([int]$Row)
2020-12-22 09:24:30 +01:00
switch($Row) {
1 { return ".o" }
2 { return "oo" }
3 { return "oo" }
}
}
2021-01-27 15:12:17 +01:00
function Braille2 { param([int]$Row)
2020-12-22 09:24:30 +01:00
switch($Row) {
1 { return ".o" }
2 { return ".o" }
3 { return "oo" }
}
}
2021-01-27 15:12:17 +01:00
function Braille3 { param([int]$Row)
2020-12-22 09:24:30 +01:00
switch($Row) {
1 { return ".." }
2 { return "oo" }
3 { return "oo" }
}
}
2021-01-27 15:12:17 +01:00
function Braille4 { param([int]$Row)
2020-12-22 09:24:30 +01:00
switch($Row) {
1 { return ".." }
2 { return "o." }
3 { return "oo" }
}
}
2021-01-27 15:12:17 +01:00
function Braille5 { param([int]$Row)
2020-12-22 09:24:30 +01:00
switch($Row) {
1 { return ".o" }
2 { return "o." }
3 { return "oo" }
}
}
2021-01-27 15:12:17 +01:00
function Braille6 { param([int]$Row)
2020-12-22 09:24:30 +01:00
switch($Row) {
1 { return ".." }
2 { return ".o" }
3 { return "oo" }
}
}
2021-01-27 15:12:17 +01:00
function Braille7 { param([int]$Row)
2020-12-22 09:24:30 +01:00
switch($Row) {
1 { return ".." }
2 { return ".." }
3 { return "oo" }
}
}
2021-01-27 15:12:17 +01:00
function Braille8 { param([int]$Row)
2020-12-22 09:24:30 +01:00
switch($Row) {
1 { return ".o" }
2 { return ".." }
3 { return "oo" }
}
}
2021-01-27 15:12:17 +01:00
function Braille9 { param([int]$Row)
2020-12-22 09:24:30 +01:00
switch($Row) {
1 { return "o." }
2 { return ".o" }
3 { return "oo" }
}
}
2021-01-27 15:12:17 +01:00
function Braille0 { param([int]$Row)
2020-12-22 09:24:30 +01:00
switch($Row) {
1 { return "o." }
2 { return ".." }
3 { return "oo" }
}
}
2021-01-27 15:12:17 +01:00
function BrailleChar { param([string]$Char, [int]$Row)
2020-12-22 09:24:30 +01:00
switch($Char) {
'A' { return BrailleA $Row }
'B' { return BrailleB $Row }
'C' { return BrailleC $Row }
'D' { return BrailleD $Row }
'E' { return BrailleE $Row }
'F' { return BrailleF $Row }
'G' { return BrailleG $Row }
'H' { return BrailleH $Row }
'I' { return BrailleI $Row }
'J' { return BrailleJ $Row }
'K' { return BrailleK $Row }
'L' { return BrailleL $Row }
'M' { return BrailleM $Row }
'N' { return BrailleN $Row }
'O' { return BrailleO $Row }
'P' { return BrailleP $Row }
'Q' { return BrailleQ $Row }
'R' { return BrailleR $Row }
'S' { return BrailleS $Row }
'T' { return BrailleT $Row }
'U' { return BrailleU $Row }
'V' { return BrailleV $Row }
'W' { return BrailleW $Row }
'X' { return BrailleX $Row }
'Y' { return BrailleY $Row }
'Z' { return BrailleZ $Row }
'1' { return Braille1 $Row }
'2' { return Braille2 $Row }
'3' { return Braille3 $Row }
'4' { return Braille4 $Row }
'5' { return Braille5 $Row }
'6' { return Braille6 $Row }
'7' { return Braille7 $Row }
'8' { return Braille8 $Row }
'9' { return Braille9 $Row }
'0' { return Braille0 $Row }
}
return " "
}
try {
2021-09-25 19:43:22 +02:00
if ($text -eq "" ) { $text = read-host "Enter text to write" }
[char[]]$ArrayOfChars = $text.ToUpper()
2020-12-22 09:24:30 +01:00
write-output ""
for ($Row = 1; $Row -lt 4; $Row++) {
$Line = ""
foreach($Char in $ArrayOfChars) {
$Line += BrailleChar $Char $Row
$Line += " "
}
write-output $Line
}
write-output ""
2021-09-27 10:09:45 +02:00
exit 0 # success
2020-12-22 09:24:30 +01:00
} catch {
2022-04-13 12:06:32 +02:00
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
2020-12-22 09:24:30 +01:00
exit 1
}