I would start off by learning about Variables, Basic Data Types and maybe enumerations. Then skip the reset of the lessons in level 2 and come back when you want to learn more.
Definition: Variables - They hold values that can change over time. A Variable is a name that is associated with a value.
Example: You could make a variable called temperature. The value in temperature can be changed.
Code Syntax: iTemperature := 90; // Notes- Temperature is set at 90 Degrees.
Variables can be of any data type. You could have made your variable called iTemperature a type DINT, LREAL, and more.
Variable Declaration: iTemperature : INT; //Notes- Value of data type INT.
Definition: Data Types - They are simply type of a classification which tells the compiler how the programmer intends to use the data.
Example 1: A data type of BOOL, can only have 1 of 2 values. True or False.
Example 2: A data type of UINT, can have value from 0 to 65535.
NOTES: Most common data types could probably be debated but I find more often than not i use, BOOL, INT, DINT, LREAL. But you will use other types too.
List of Data Types
Name, value range, Memory size
BOOL, True=1 -> False =0, 8 bit
BYTE, 0 -> 255, 8 bit
WORD, 0 -> 65535, 16 bit
DWORD, 0 -> 4294967295, 16 bit
LWORD, 0 -> 2^64 OR 18446744073709600000, 64 bit
SINT, -128 -> 127, 8 bit
USINT, 0 -> 255, 8 bit
INT, -32768 -> 32767, 16 bit
and more
Definition: Enumeration - Is a data type consisting a set of named values to replace normal values.
Example 1: Lets say you wanted a variable that did not show a number but showed a word that represented a value. This would be a great place for a Enum.
Example 2: Lets say you wanted something called eError. You wanted the eError to show a word to the program and not just a value. Lets say you wanted 0 = NA, 1=OK, -1 =error, -2 = Out of range.
Code Syntax:
TYPE eErrors : (
NA :=0, OK :=1, Error := -1, OutOfRange := -2
)INT; END_TYPE
Variable Declaration:
MyError : eErrors ; //Notes - This is how to Declare a custom Enum.
Definition: Data Types - These types let a Variables hold more then 1 value at a time.
Example 1: Lets say you are making a simple video game. You could use a structure called Player. This player would have many variables inside it. Some of the things you might want your player to know is, Is it good or bad, what color is it, what is its health level, and more.
Example 2: Let's say you wanted to keep all your index values under one variable, like acceleration, deceleration, speed, distance. You would make a structure called Indexs or something.
Variable Declaration:
MyIndex_1: Indexs ; //1st index that has all of the var in it
MyIndex_2: Indexs ; //2nd index that has all of the var in it.
Our mission is simple: Help new programmers learn to program. Too many times we have seen others looking for or re-creating the same things over and over. We feel this needs to stop. If we find someone that has produce a quality video we will share it with you. We will strive to make learning as easy as we can without re-creating if possible.