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™

1 comment:

  1. React Native ist ein beliebtes Framework zur Entwicklung plattformübergreifender mobiler Apps. Mit React Native können Entwickler effizient Apps für iOS und Android erstellen, da der Großteil des Codes für beide Plattformen wiederverwendet werden kann. Durch die Verwendung von JavaScript ermöglicht React Native die schnelle Entwicklung ansprechender und leistungsstarker Apps. Das Framework bietet eine Vielzahl von vorgefertigten Komponenten und ermöglicht die Integration von nativen Funktionen. Erfahren Sie mehr über die Vorteile der React Native App Entwicklung und wie Sie Ihr eigenes plattformübergreifendes Projekt starten können. native app development

    ReplyDelete

New In-feed ads