- Aug
- 2,840
- 149
ReverseWords.ps1 is a script to accept a string of words,
and display them to the console in reverse order.
I have ReverseWords.ps1 in my path,
E:\Utils\ReverseWords.ps1
I gave DuckAI the script I had written,
and asked it to generate the comment-based help.
Thus, now I can get detailed help for ReverseWords.ps1 from the TCC command line.
Another option is to create an alias for ReverseWords;
ReverseWords.ps1
Joe
and display them to the console in reverse order.
I have ReverseWords.ps1 in my path,
E:\Utils\ReverseWords.ps1
Code:
R:\>which psc
psc is an alias : pshell /s %@quote[%$]
Code:
R:\>psc reversewords One Two Three
Three Two One
Code:
R:\>psc reversewords One,Two,Three
Three Two One
Code:
R:\>psc reversewords "One","Two","Three"
Three Two One
I gave DuckAI the script I had written,
and asked it to generate the comment-based help.
Thus, now I can get detailed help for ReverseWords.ps1 from the TCC command line.
Code:
R:\>psc get-help reversewords.ps1
NAME
e:\utils\ReverseWords.ps1
SYNOPSIS
Reverses the order of words in a string.
SYNTAX
e:\utils\ReverseWords.ps1 [[-InputWords] <String[]>] [<CommonParameters>]
DESCRIPTION
Accepts words as a single quoted string or as separate arguments,
then outputs them in reverse order.
RELATED LINKS
REMARKS
To see the examples, type: "get-help e:\utils\ReverseWords.ps1 -examples".
For more information, type: "get-help e:\utils\ReverseWords.ps1 -detailed".
For technical information, type: "get-help e:\utils\ReverseWords.ps1 -full".
Another option is to create an alias for ReverseWords;
Code:
R:\>which reversewords
ReverseWords is an alias : pshell /s e:\utils\ReverseWords.ps1
R:\>reversewords One Two Three
Three Two One
ReverseWords.ps1
Code:
<#
.SYNOPSIS
Reverses the order of words in a string.
.DESCRIPTION
Accepts words as a single quoted string or as separate arguments,
then outputs them in reverse order.
.PARAMETER InputWords
The words to reverse.
.EXAMPLE
u:\ReverseWords.ps1 'One Two Three'
Three Two One
.EXAMPLE
E:\utils\ReverseWords.ps1 One Two Three
Three Two One
#>
param(
[Parameter(ValueFromRemainingArguments)]
[string[]]$InputWords
)
$s = $InputWords -join ' '
$words = $s -split '\s+'
[array]::Reverse($words)
$words -join ' '
Joe