DEFINING VARIABLES

FEW OTHER KEYWORD ARE :

  • DATA :-
It defines global and local variables. Variables have a particular data type.

Syntax :

 Data : <variable_name> type <data_type>

Example :

 Data : f .

Field f is created that has a data type char.
Char is a default data type.

Field f can be up to 30 characters long. special characters are not allowed ('+','-','.',',') . Numeric characters are allowed buut should be accompanied with alphabets. Space cannot be used as it is a reserved word.

Recommendation for field name will be :-

Always use a letter as the first character. And a underscore to join two words. Hyphen is not used.

If we write :

Data : name type c .

name = 'abc' .

write name .

Output : a

So with characters we have to define length too.

Same Example can be corrected as :

Data : name(10) type c value 'abc'.

Here we are giving value specification .

Another method is by using 'move' keyword.

Data : name(10) type c .

move 'abc' to name .

write name .

Some times we do not wish to change the value assigned to a variable in that case we can declare a variable as constant.

constant : name (10) type c value 'abc' .

By doing so value of name cannot be changed or overridden . 

No comments:

Post a Comment