Mumpster
http://mumpster.org/

Unit 2 - Lesson 5: Expressions – Data Types: Strings
http://mumpster.org/viewtopic.php?f=29&t=816
Page 1 of 1

Author:  tlwiechmann [ Thu Jun 02, 2011 10:17 am ]
Post subject:  Unit 2 - Lesson 5: Expressions – Data Types: Strings

This lesson covers the concept of a string in detail and there is not much to add. Because there is only one data type, the string, understanding how the system converts a string to a number is very important. The conversion is context dependent.

First, the command context determines the evaluation. The command argument contains an expression that must evaluate to one of the levels depicted in the diagram at the beginning of the lesson. For example, the argument of an IF command is an expression that must evaluate to a truth value.

Second, the expression itself can determine the context. This is amply illustrated by the examples in the lesson. For example:

> WRITE “22 aardvarks”
produces
22 aardvarks
however,
WRITE +”22 aardvarks”
produces
22

The process is quite simple, if the context of the expression dictates a numeric evaluation, the string is scanned for numerics left to right until a non-numeric is encountered.

Exercise

Do the exercise at the end of the lesson. If you do not understand the results you are getting, please ask questions.
Play with some values in direct mode.


When we get to Operators, we will visit this concept again especially when dealing with arithmetic operations.

Page 1 of 1 All times are UTC - 8 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/