Sunday, September 18, 2016

What is a string value...?

What is a string value ?
Seems like a fair question. Five simple words.

Computational thinking can help us to solve this most interesting question.
Type into the shell your name.
An error message will be displayed. In my example the host console screen displays this error message:
...
Steve : The term 'Steve' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Steve
+ ~~~~~
+ CategoryInfo : ObjectNotFound: (Steve:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
The error message is very informative.
First it echoes the input requesting action from the system. In my example it outputs my name Steve followed
by a colon separator and the familiar "The term 'steve' is not recognized as the name of a cmdlt, function, script file,
or operable program..." Notice that in the output of the error message that the data expressed in the part, 'The term 'Steve', is
in single quotes. A clue.
The experience of PowerShell is interactive. Interactive means that PowerShell is doing at least three things. It is
accepting input, interprting it, and operating upon it. This is fundemental I know, but, it is not trivial. It is interactive.
The error message encourages us to '...and try again.'
So we type: 'Steve' (with single quotes) and PowerShell quickly echoes to the hosts console screen: Steve
All is right with the world.
I then type '55555' (with the single quote marks) and the engine echoes to the hosts console monitor: 55555
As was to be expected.
I type 55555 (with no single qoute marks) and the engine displays 55555.
I type: 12 + 2.
The engine displays 14.
Hmmmm.

No comments:

Post a Comment