A variable is simply a chunck of memory used to store information
To create an variable in Global code, you have to follow this template:
- Code: Select all
datatype name;
Datatype is the type of data you want to store (number, decimal, etc). You must replace it with int (number), char (text character), or float (decimal). Then you have to replace "name" with whatever you want to call the variable. Here's an example:
- Code: Select all
int MyVariable;//Creates a variable called "MyVariable" that stores a number
Now an array is simply a line of variables that all share the same name. Here's how you create an array:
- Code: Select all
datatype name[number];
As you can see, this is just like declaring a variable except you have those brackets with a number inside. The number stands for how many variables you want the array to store. For example, if you replace it with 5, the array will store five variables starting at 0 and ending at 4. Here's an example of declaring an array:
- Code: Select all
int MyArray[5];//Creates five variables that store numbers
Now, to access a variable from an array, you need to give the name of the array followed by the number of the variable you want to call surrounded by brackets. That might sound confusing but it's really easy. Here's what it looks like:
- Code: Select all
int MyArray[5];//Creates five variables that store numbers
MyArray[0] = 10;//Sets the first variable equal to ten
MyArray[1] = 8;//Sets the second variable equal to eight
MyArray[2] = 6;//Sets the third variable equal to six
MyArray[3] = 4;//Sets the fourth variable equal to four
MyArray[4] = 2;//Sets the fifth variable equal to two
Now, it's important to remember, that an array variabel and a normal variable are actually the same thing, and you can use them with eachother. Here's an example:
- Code: Select all
int MyVariable;//Creates a variable called "MyVariable" that stores a number
int BobsVariable;//Creates a variable called "BobsVariable" that stores a number
int JanesArray[2];//Creates an array called "JanesArray" that stores two numbers
JanesArray[0] = 5;//Sets the first variable equal to five
JanesArray[1] = 8;//Sets the second variable equal to eight
MyVariable = JanesArray[0];//Sets "MyVariable" equal to the first variable in "JanesArray"
BobsVariable = JanesArray[0];//Sets "BobsVariable" equal to the second variable in "JanesArray"
Now, in your case, you want an array called "data" that stores ten text characters. You can create that in Global Code like this:
- Code: Select all
char data[10];
If you do that, then your code should work just fine
If you have questions, or if I made any grammatical errors, etc, then post here or send me a PM
-Sonic-