Recent Changes - Search:

Introduction to Microcontroller Programming

About PICmicro Chips

Clocking Your PICmicro Devices

E-Blocks

Flowcode Step By Step

PICmicro Projects

Labs

Using String Variables

<^< Exploring the Keypad | Course Index | ASCII >^>

Strings are collections of Byte variables. A string can be used to store a sequence of numbers or a sequence of letters. When you declare a string of a certain length, you actually declare an array of Byte variables where the number of bytes corresponds to the string length. Every character of the string you declare is stored as a 8 bit value in a separate byte in the RAM memory. For example: if you declare this: text[4], then the text in the string variable 'text' can be 4 characters long. In fact this string variable could be used to store the word 'JOHN' in.

If you don't declare a size next to the name of your string variable, Flowcode will set it to the default size of 20. Beware of the maximum of 512 8-bit variables that can be stored in the PIC16F1937.

Arrays

You may have come across Array variables before. In Flowcode Strings and Arrays are equivalent. Arrays are 2 or more variables with the same name and a different 'member number' between square braces. e.g. if you declare a string as: MY_ARRAY[8], then 8 different 8-bit variables are declared at once. They can all be addressed separately by adding the correct member number between square braces: in this case MY_ARRAY[0] to MY_ARRAY[7]. Strings / Arrays are used in cases where a number of similar variables are needed.

<^< Exploring the Keypad | Course index | ASCII >^>

Print - Search - Login

Page last modified on April 30, 2013, at 01:54 PM