Wednesday 20 August 2008

Get-Int16.ps1

<#
.SYNOPSIS
Illustrates Int16 data type
.DESCRIPTION
This script creates,displays and formats an Int16.
.NOTES
File Name : Get-Int16.ps1
Author : Thomas Lee - tfl@psp.co.uk
Requires : PowerShell V2
.LINK
http://pshscripts.blogspot.co.uk
.EXAMPLE
PSH [C:\foo]: .\get-int16.ps1
4142
The value of this int16 is: 4142
The value of this int16 is: 4,142

Min value of an Int16 is: -32,768
Max value of an Int16 is: 32,767
#>

##
# Start of Script
##


# Create the int16

[system.int16] $i = 0

# set and display a value:
$i=4142
$i
'The value of this int16 is: {0}' -f $i

# and nicely formatted
'The value of this int16 is: {0}' -f $i.tostring('0,000')
''

# Max/Min value
'Min value of an Int16 is: {0}' -f [System.Int16]::minvalue.tostring('0,000')
'Max value of an Int16 is: {0}' -f [System.Int16]::maxvalue.tostring('0,000')
# End of script

1 comment:

Hal said...

If I may make a suggestion--I'm not sure that you are providing as much value as you could when you post these scripts without any background for them or explanation of how they work. If all you want to do is "dump" scripts out there, we (I'm speaking on behalf of PowerShellCommunity.org) would greatly appreciate seeing those entered into PoshCode.org. That way they will be in a searchable respository that already has integration with powershell (see http://huddledmasses.org/automating-the-powershell-script-repository/), and PowerGUI (see http://dmitrysotnikov.wordpress.com/2008/07/28/powershell-cpan/).

On the other hand, if you *really* want to add value, I'd recommend slowing down on the pace. For each article you may want to consider writing the background for why you wrote it and then explain to new users how it works. Or something along those lines.

Just trying to spread knowledge as far and wide as I can! (with my $0.02 worth)

-hal
Community Director, PowerShellCommunity.org