Showing posts with label REXX AUTOMATION. Show all posts
Showing posts with label REXX AUTOMATION. Show all posts

Saturday, 27 February 2021

REXX Tutorial: Rexx - DataType | Data Types in REXX and Syntax Tutorial.

Rexx Tutorial, Rexx datatypes, Rexx built-in functions, rexx functions

REXX Data Types.

Welcome back to today's Rexx tutorial on Rexx Datatype. In this Rexx tutorial, you'll learn the different categories of data types in REXX. You'll also learn how to define and use variables, character strings, numbers, and operators in Rexx programs. Each category of Rexx data type is explained with an example. By the end of this zos Rexx tutorial, you'll be able to write simple Rexx programs. Let's get started with Rexx Data Type Introduction.

Rexx Introduction.    

The term, REXX stands for REstructured eXtended eXecutor. REXX is a very useful, robust, and versatile scripting language. REXX is actually a forerunner to all these other scripting languages mentioned above. 

What are Data Types in Rexx? 

The ability to process data to get a result is one of the most powerful aspects of computer programming. Rexx is a powerful and robust programming language. The beauty of the zos Rexx is that you're not required to define the variable type. In fact, Rexx internally handles the variable datatype.  You need to define, initialize and use the variable as per business requirements. 

In other programming languages such as COBOL, JAVA, VB.Net, you need to explicitly define the type of the variable. 

Now, the question is why do you have Data types in Rexx?

Well, the answer is Rexx has an inbuilt datatype. It means, that once the value is assigned to a variable or initialized. Rexx internally assigns a data type to the defined variable.  

The Rexx datatypes are broadly categorized into the following category: 
  • Numeric (NUM) 
  • Character (CHAR)
Now, let's discuss each category in more detail. 

  • Numeric (NUM) in Rexx: As the name suggests NUM represents numeric data. It's like SMALL INT, DECIMAL, FLOAT of other programming languages. But, Rexx treats all different types of numeric data as Numeric. In fact, a number with the decimal ('.') is considered numeric. 
  • Character (CHAR) in Rexx: As the name suggests CHAR represents alphanumeric data. It includes null string, special character, alphabets, or any other combination of character and numbers. All such combinations are treated as a char data type in REXX. 
You can write a REXX statement in lowercase, uppercase, or mixed case. But, alphabetic characters are changed to uppercase, unless you enclose them in single or double quotation marks.

If you do not specify string in quotes, then Rexx will convert the string into upper case. But, if you specify string in quotes or double quotes then Rexx would retain the case of the input string. Refer to the following sample Rexx code.   

Example 1. Rexx Sample Code.
 
\******* Rexx Example ********
 SAY 'This is a REXX tutorial.'
 SAY  This is a REXX tutorial.

Output. 
 This is a REXX tutorial.
 THIS IS A REXX TUTORIAL.

Rexx has many inbuilt functions, you can use these Rexx functions to accomplish various project requirements. One such Rexx function is DATATYPE, this function can be used to check data-type assigned by Rexx internally. 

Now, let's try to understand the usage of these data types with the help of a sample Rexx Code. 

Example 2. Rexx Numeric Variable. 
 
\********** Rexx Sample Code **********.
   mnth_sal = 500
   SAY 'Employee Monthly Sal:' mnth_sal '.'

Output - Employee Monthly Sal: 500

Example 3. Rexx Character Variable. 

\********** Rexx Sample Code **********.
 emp_name = David
 SAY 'Name of Employee:' emp_name 

Output - Name of Employee: David

REXX Datatype Function. 

As you know that REXX provides many built-in functions. One such function is the DATATYPE function. This Rexx Function is important and extensively used to find the data type of input string. Refer to the following example. 

\********** Rexx Sample Code **********.
 SAY DATATYPE("123")
 SAY DATATYPE("123.4")

Output - NUM

\********** Rexx Sample Code **********.
 SAY DATATYPE("123")
 SAY DATATYPE("123#")

Output - CHAR

DATATYPE('DATA', 'TYPE'): In this case, the first argument has the data, and the second argument has the type of data. Now if the data and the type match then this command will return '1' which means it's true and if there is a mismatch then it returns '0' which means false.

\********** Rexx Sample Code **********.
 SAY DATATYPE("123","N")
 SAY DATATYPE("ABC","A")
 
Output: Return 1 as datatype matches. 

REXX Instruction Format. 

As you know, that Rexx is a free format programming language. It means you are allowed to include additional space between words or blank lines freely within the business logic. In general, you have one instruction per line. But, you can use comma (,) to continue instruction to the second line. Refer to the following example. 

Example 4. Rexx instruction continuation. 

\********** Rexx Sample Code ***************************.
 SAY 'This is the ZOS REXX datatype', 
 SAY 'tutorial.'  

Output - This is the ZOS REXX datatype tutorial.

A semicolon indicates the end of an instruction. In fact, you can use a semicolon (;) to specify multiple Rexx instructions. Refer to the following example. 
 
Example 5. Rexx instruction end.

\********** Rexx Sample Code ***************************.
 SAY 'ZOS REXX datatype.'; SAY 'Rexx builtin functions.'  

Output - ZOS REXX datatype.
         Rexx builtin functions.
 

Type of Rexx Instructions. 

In Rexx, there are five kinds of REXX instructions: keyword, assignment, label, null, and command. Let's look at the description of each instruction with an example. 

  • Rexx Keyword: An instruction with a keyword tells the language processor to do something. For example, SAY or PULL.
  • Rexx Assignment: An assignment assigns a value to an attribute or modifies its current value. For example: mnth_sal = 500.
  • Rexx labels: A symbolic name followed by a colon is called a label. A label can contain a single character or double character. For example MNTH:
  • Rexx NULL: In Rexx null or a blank line is treated as a comment. The language process ignores such lines. 
  • Rexx Command: An instruction that is not a keyword instruction, assignment, label, or null is processed as a command and is sent to a previously defined environment for processing. For example TIME.
Conclusion. 

Finally, this marks an end to our today's Rexx Datatype tutorials. In this session, you learn how to define and use various datatypes in Rexx. You also learn, how to use the datatype built-in function. Don't forget to join us for the next tutorial on "How to write and execute Rexx Programs"

►Subscribe to Topictrick & Don't forget to press THE BELL ICON to never miss any updates. Also, Please visit mention the link below to stay connected with Topictrick and the Mainframe forum on - 

► Youtube
► Facebook 
► Reddit

Thank you for your support. 
Mainframe Forum™

Saturday, 20 February 2021

REXX Tutorial: REXX Programming Language | Mainframe REXX Tutorial | REXX Introduction.


REXX Tutorial, REXX Programming Language, Mainframe REXX

REXX - REstructured eXtended eXecutor


Welcome back to today's session on REXX Programming Language or TSO/REXX. In this session, you'll get an overview of the Mainframe REXX scripting language. Followed by REXX features and how mainframe REXX played a vital role in automating the task. Let's start today's tutorial with a question. 

Question. If I ask which all scripting languages you guys are aware of?

Few languages that most of you will think of would be Python or Perl or PHP. But, there is one more language that is REXX. It's used on IBM Mainframe to an automated daily task. REXX is the powerful and oldest scripting language available on Mainframes. 


REXX Tutorial


What is REXX?

The term, REXX stands for REstructured eXtended eXecutor. REXX is a very useful, robust, and extremely versatile scripting language. What is more shocking is REXX is actually a forerunner to all these other scripting languages mentioned above. 

Now, most of you might have this doubt that why have we not heard of it then?  

The reason being REXX is a very old language. It was developed by IBM in the 1970s. It gained popularity and was used extensively in the 1990s. It is still being used by a lot of programmers for creating tools to reduce manual efforts.

REXX is a free format scripting programming language. REXX is also available on a different computing platforms such as LINUX, DOS.

REXX Code Example. 

/**************** REXX *********************************/
SAY 'This is a my first REXX program!'

Features of REXX. 

REXX is a powerful and robust programming language. It has many other features, a couple of which are listed below:

Easy to Code and Free Formatted: 

  • REXX is a very versatile general-purpose programming language. You can easily learn and use to automate your daily task without any hassle. REXX is an English-like language you can easily read and understand the REXX program. A very simple example to demonstrate this would be: We give a command called 'SAY' to display anything on the screen and 'PULL' to actually take the input from the end-user. 
  • REXX is a free format programming language, so you're not required to learn additional formatting rules such as COBOL, JAVA, etc. Programmer can literally code from the first column in line 1 and then from the fifth column in line 2.
  • Variable type declaration is never an issue with REXX. You can directly use the variable and the first time the value is pushed to a variable it gets declared with that type.
  • REXX programs are not case-sensitive. It means, upper and lower case is treated as same. The programmer is free to use any case or mix cases as per requirements.

Full of Integrate yet Relevant Functions:

  • REXX programming language has a lot of in-built functions. You can call these functions to perform complex calculations instead of writing complex logic for easy operations. These functions include arithmetic calculation functions, search functions, formatting functions, comparison functions, etc. 

Capabilities to Debug the Code:

  • A programming language is incomplete if there is no debugging facility associated with it. It's easy to write code but it gets extremely difficult to find and fix bugs in your programs. If you tend to run REXX in the TSO/E environment and the code encounters an error, suitable messages are displayed on the screen itself. 
  • Not only this the REXX programming language even has a 'TRACE' option with which you can easily debug your code and find the errors very accurately.

Parsing Capabilities:

  • Parsing as most of you might know is the ability to split a sentence into different parts. REXX has extensive parsing capabilities for string manipulation. Most of the daily requirements are related to string manipulation. This parsing capability of REXX makes it the cream of the crop.

REXX Components:

  • REXX programming language is a combination of four components are Instructions, Inherent Functions, External Functions, and Data Stack Functions.
  • The Instructions comprised of Keyword, Assignment, Label, Null, TSO/E REXX commands, and Host Commands.
  • Inherent functions are functions that are built internally for the REXX processor and are used for various purposes.
  • External Functions are primarily provided by TSO/E and it actually interacts with the system to perform many tasks for this programming language.
  • Stack Functions are basically the functions that are used to store data for Input/ Output and other types of processing.

Conclusion:

Finally, this was all about the introduction to REXX or REXX Programming Language. In this REXX tutorial, you studied the Rexx history, features, and components of REXX. The REXX introduction tutorial is to lay the foundation for the next upcoming REXX tutorials. I hope you understood the basics of REXX. Please feel free to pin down your doubts or suggestions in the comment section. See you soon in another Rexx Tutorial


►Subscribe to Topictrick & Don't forget to press THE BELL ICON to never miss any updates. Also, Please visit mention the link below to stay connected with Topictrick and the Mainframe forum on - 

► Youtube
► Facebook 
► Reddit

Thank you for your support. 
Mainframe Forum™

New In-feed ads