GNVQ Advanced ITPossible program constructs:
FOR/DO, WHILE/DO, REPEAT/UNTIL loops
Data is stored in computer memory and the translation program has to decide where to store the data and how much space to reserve, so the program code must indicate what type of data is to be stored.
Data types can be
Common structures
There are three basic types of programming expressions:
+
- / * ^
E.g.
count:=count + 1
average:=total/count
= <
> <= >= <>
e.g. IF salary < 4000 THEN
tax:=0
Logical operators: NOT AND OR see also Boolean operator
e.g. IF mark >=70 AND mark <=80 THEN grade:= "B"
An operator which is not concerned with any of the above expressions is: concatenation. this is the term applied to string manipulation, in particular the joining of one or more strings together to form another string.
e.g. fullname:= title + firstname + surname
The + operator in this instance is not adding numerically
but joining
Compiler:
A compiler attempts to translate all the source
code (instructions you have written) at one go into the 'native'
language of the computer (1010101010101010); flagging any syntax errors
it finds in the process. Linking of the object code produced
and running the resultant executable file is done as a separate process.
Humans find the machine code (1010101010101010), which the computer understands, unnatural, difficult and innefficient to use. Therefore very few programs are written directly in this language.
Pascal is an example of a high level language, closer to English. It is a compromise, going halfway to meet the computer. The role of a compiler is that of a translator; taking the high level program created and completes the translation into the native machine code of the computer. This final code is sometimes referred to as object code)
Because a high level language such as Pascal is highly structured the compiler can fulfill another duty (error checking) by ensuring that the object code is correctly formed according to the rules of Pascal. If any syntax errors are detected it is reported back to the user who then needs to re-edit the source code and re-compile.
Interpreter:
An intepreter differs from a compiler, as it attempts
to translate and then run each statement in turn. This is a slower
method than compilation, since translation is necessary every time the
program is run. A second disadvantage is that since the interpreter
stops when an error is encountered or the end of the program is reached,
only the first error is found in each run.
see also script,
JavaScript
and VBScript
|
|
|
|