Rexx – Strings

Rexx – Strings ”; Previous Next Strings in Rexx are denoted by a sequence of characters. The following program is an example of strings − Live Demo /* Main program */ a = “This is a string” say a The output of the above program is as follows − This is a string Let’s discuss some methods which are available in Rexx for strings. Sr.No. Methods available in Rexx for Strings 1 left This method returns a certain number of characters from the left of the string. 2 right This method returns a certain number of characters from the right of the string. 3 length This method returns the number of characters in the string. 4 reverse This method returns the characters in a reverse format. 5 compare This method compares 2 strings. Returns “0” if “string1” and “string2” are identical. Otherwise, it returns the position of the first character that does not match. 6 copies This method copies a string n number of times. 7 substr This method gets a sub string from a particular string. 8 pos This method returns the position of one string within another. 9 delstr This method deletes a sub string from within a string. Print Page Previous Next Advertisements ”;

Rexx – Stacks

Rexx – Stacks ”; Previous Next The stack is sometimes called the external data queue, but we follow common usage and refer to it as the stack. It is a block of memory that is logically external to Rexx. Instructions like push and queue place data into the stack, and instructions like pull and parse pull extract data from it. The queued built-in function reports how many items are in the stack. Let’s take a look at an example of a stack. /* STACK: */ /* */ /* This program shows how to use the Rexx Stack as either a */ /* stack or a queue. */ do j = 1 to 3 push ‘Stack: line #’ || j /* push 3 lines onto the stack */ end do j = 1 to queued() /* retrieve and display LIFO */ pull line say line end do j = 1 to 3 queue ‘Queue: line #’ || j /* queue 3 lines onto the stack */ end do queued() /* retrieve and display FIFO */ pull line say line end exit 0 The first do loop in the program places three lines of data onto the stack. It uses the push instruction to do this. We number the lines so that when they are retrieved in the LIFO order their order is apparent. The items placed into the stack by the push instruction are retrieved in the LIFO order − do j = 1 to 3 push ‘Stack: line #’ || j /* push 3 lines onto the stack */ end The next code block shows the use of the queued built-in function to discover the number of lines on the stack, as well as a loop to retrieve all the lines from the stack − do j = 1 to queued() /* retrieve and display LIFO */ pull line say line end Since the three items were placed on the stack via push, they are retrieved in the LIFO order. The output of the above program will be as follows. STACK: LINE #3 STACK: LINE #2 STACK: LINE #1 Print Page Previous Next Advertisements ”;

Rexx – Decision Making

Rexx – Decision Making ”; Previous Next Decision making structures require that the programmer specify one or more conditions to be evaluated or tested by the program. The following diagram shows the general form of a typical decision-making structure found in most of the programming languages. There is a statement or statements to be executed if the condition is determined to be true, and optionally, other statements to be executed if the condition is determined to be false. Let’s look at the various decision-making statements available in Rexx. Sr.No. Statement & Description 1 If statement The first decision-making statement is the if statement. An if statement consists of a Boolean expression followed by one or more statements. 2 If-else statement The next decision-making statement is the if-else statement. An if statement can be followed by an optional else statement, which executes when the Boolean expression is false. Nested If Statements Sometimes there is a requirement to have multiple if statements embedded inside each other, as is possible in other programming languages. In Rexx also this is possible. Syntax if (condition1) then do #statement1 end else if (condition2) then do #statement2 end Flow Diagram The flow diagram of nested if statements is as follows − Let’s take an example of nested if statement − Example Live Demo /* Main program */ i = 50 if (i < 10) then do say “i is less than 10” end else if (i < 7) then do say “i is less than 7” end else do say “i is greater than 10” end The output of the above program will be − i is greater than 10 Select Statements Rexx offers the select statement which can be used to execute expressions based on the output of the select statement. Syntax The general form of this statement is − select when (condition#1) then statement#1 when (condition#2) then statement#2 otherwise defaultstatement end The general working of this statement is as follows − The select statement has a range of when statements to evaluate different conditions. Each when clause has a different condition which needs to be evaluated and the subsequent statement is executed. The otherwise statement is used to run any default statement if the previous when conditions do not evaluate to true. Flow Diagram The flow diagram of the select statement is as follows The following program is an example of the case statement in Rexx. Example Live Demo /* Main program */ i = 50 select when(i <= 5) then say “i is less than 5” when(i <= 10) then say “i is less than 10” otherwise say “i is greater than 10″ end The output of the above program would be − i is greater than 10 Print Page Previous Next Advertisements ”;

Rexx – Overview

Rexx – Overview ”; Previous Next Rexx (Restructured Extended Executor) is designed to be a scripting language. Its goal is to make scripting as easy, fast, reliable, and error-free as possible. Many programming languages are designed for compatibility with older languages, and are written for specific audiences or platforms. Rexx ignores extraneous objectives. It was designed from day one to be powerful, yet easy to use. Rexx was designed and first implemented, in assembly language, as an ”own-time” project between 20th March 1979 and the middle of 1982 by Mike Cowlishaw of IBM, originally as a scripting programming language to replace the languages EXEC and EXEC 2. It was designed to be a macro or scripting language for any system. As such, Rexx is considered a precursor to Tcl and Python. Rexx was also intended by its creator to be a simplified and easier to learn version of the PL/I programming language. Features of Rexx Rexx as a programming language has the following key features − Simple syntax The ability to route commands to multiple environments The ability to support functions, procedures and commands associated with a specific invoking environment. A built-in stack, with the ability to interoperate with the host stack if there is one. Small instruction set containing just two dozen instructions Freeform syntax Case-insensitive tokens, including variable names Character string basis Dynamic data typing, no declarations No reserved keywords, except in local context No include file facilities Arbitrary numerical precision Decimal arithmetic, floating-point A rich selection of built-in functions, especially string and word processing Automatic storage management Crash protection Content addressable data structures Associative arrays Straightforward access to system commands and facilities Simple error-handling, and built-in tracing and debugger Few artificial limitations Simplified I/O facilities The official website for Rexx is www.oorexx.org Print Page Previous Next Advertisements ”;

Rexx – Arrays

Rexx – Arrays ”; Previous Next Arrays in any programming language allow you to group a list of values of the same type. The use of arrays is that it allows you to build a list of similar type of values which are sortable, searchable and can be easily manipulated. Rexx also allows one to define arrays. These arrays can be one dimensional or multidimensional. Rexx arrays may be sparse. That is, not every array position must have a value or even be initialized. There can be empty array positions, or slots, between those that do contain data elements. Or arrays can be dense, in which consecutive array slots all contain data elements. In many programming languages, you must be concerned with what the subscript of the first entry in a table is. Is the first numeric subscript 0 or 1? In Rexx, the first subscript is whatever you use! So, input the first array element into position 0 or 1 as you prefer. array_name.0 = ‘first element’ or array_name.1 = ‘first element’ Let’s look at the different operations available for arrays. Creating Arrays Arrays are created with the same naming convention which is used for variables in Rexx. The general syntax for creating arrays is as follows − Arrayname.index = value where Arrayname − This is the name provided to the array. Index − This is the index position in the array to refer to a specific element. Value − This is the value assigned to the index element in the array. An example of an array declaration is as follows − Example /* Main program */ list.1 = 0 list.2 = 0 list.3 = 0 The following points needs to be noted about the above program − The name of the array is given as list There are 3 elements of the array which are initialized to the value of 0. Assigning Values to an Array Element Values can be re-assigned to array elements in the same way as array elements are initialized. The following program is an example of values which can be assigned to various index values of an existing array. /* Main program */ list.1 = 0 list.2 = 0 list.3 = 0 /* Assigning new values to the array*/ list.1 = 10 list.3 = 30 Displaying Values of an Array The values of an array can be displayed by referring to the index position of the array element. The following example shows to access various elements of the array. Example Live Demo /* Main program */ list.1 = 0 list.2 = 0 list.3 = 0 /* Assigning new values to the array*/ list.1 = 10 list.3 = 30 say list.1 say list.2 say list.3 The output of the above program will be as follows − 10 0 30 Copying Arrays All of the elements of an array can be copied onto another array. The general syntax of this is as follows − Newarray. = sourcearray. where Newarray − This is the new array in which the elements need to be copied onto. Sourcearray − This is the source array from which the elements need to be copied. An example on how the copy operations for arrays can be carried out is shown in the following program − Example Live Demo /* Main program */ list.1 = 0 list.2 = 0 list.3 = 0 /* Assigning new values to the array*/ list.1 = 10 list.3 = 30 listnew. = list. say listnew.1 say listnew.2 say listnew.3 The output of the above program will be − 10 0 30 Iterating through array elements Elements of an array can also be iterated by using the iterative statements available in Rexx. An example on how this can be done is as follows − Example Live Demo /* Main program */ list.1 = 10 list.2 = 20 list.3 = 30 number_of_elements = 3 do j = 1 to number_of_elements say list.j end The following pointers need to be noted about the above program − The do loop is used to iterate through the array elements. The variable number_of_elements is used to store the number of elements in the array. The variable j is used to iterate through each element of the array. The output of the above program will be − 10 20 30 Two-dimensional Arrays It was also mentioned that we can construct multi-dimensional arrays in Rexx. Let’s look at an example of how we can implement a 2-dimensional array. Example Live Demo /* Main program */ list.1 = 10 list.1.1 = 11 list.1.2 = 12 say list.1 say list.1.1 say list.1.2 The output of the above program will be shown as follows − 10 11 12 The following point needs to be noted about the above program − To create a multidimensional array, we can use another layer of indexing. So in our example, we used list.1.1 to create another inner array for the index value 1 of the list array. Print Page Previous Next Advertisements ”;

Rexx – Home

Rexx Tutorial PDF Version Quick Guide Resources Job Search Discussion Rexx (Restructured Extended Executor) is designed to be a scripting language. Its goal is to make scripting as easy, fast, reliable, and error-free as possible. Many programming languages are designed for compatibility with older languages, and are written for specific audiences or platforms. Rexx ignores extraneous objectives. It was designed from day one to be powerful, yet easy to use. It is also very helpful for developing small programs that perform various text file transformations. This is an introductory tutorial that covers the basics of Rexx and how to deal with its various components and sub-components. Audience This tutorial has been prepared mainly for those professionals who are within the IT industry, working as specialists in the field of Scripting and Macro Languages. It is very useful for those professionals who work on Data Processing, text and also for generating reports. This tutorial is intended to make you comfortable in getting started with Restructured Extended Executor (Rexx) and its various functions. Prerequisites It is an elementary tutorial and you can easily understand the concepts explained here with a basic knowledge of how a company or an organization deals with its scripting languages and programs. However, it will help if you have some prior exposure on programming languages, data processing, and generating reports. Print Page Previous Next Advertisements ”;

Rexx – Loops

Rexx – Loops ”; Previous Next So far we have seen statements which have been executed one after the other in a sequential manner. Additionally, statements are provided in Rexx to alter the flow of control in a program’s logic. They are then classified into a flow of control statements which we will study in detail. A loop statement allows us to execute a statement or group of statements multiple times. The following illustration is the general form of a loop statement in most of the programming languages. Let us discuss various loops supported by Rexx. Sr.No. Loop Type & Description 1 do loop The do loop is used to execute a number of statements for a certain number of times. The number of times that the statement needs to be executed is determined by the value passed to the do loop. 2 do-while loop The do-while statement is used to simulate the simple while loop which is present in other programming languages. 3 do-until loop The do-until loop is a slight variation of the do while loop. This loop varies in the fact that is exits when the condition being evaluated is false. Controlled Repetition The do loops can be catered to carry out a controlled repetition of statements. Syntax The general syntax of this sort of statement is as follows. do index = start [to limit] [by increment] [for count] statement #1 statement #2 end The difference in this statement is that there is an index which is used to control the number of times the loop is executed. Secondly, there are parameters which state the value which the index should start with, where it should end and what is the increment value. Flow Diagram Let’s check out the flow diagram of this loop − From the above diagram you can clearly see that the loop is executed based on the index value and how the index value is incremented. The following program is an example of the controlled repetition statement. Example Live Demo /* Main program */ do i = 0 to 5 by 2 say “hello” end In the above program, the value of the count i is set to 0 first. Then it is incremented in counts of 2 till the value is not greater than 5. The output of the above code will be − hello hello hello Print Page Previous Next Advertisements ”;

Rexx – Environment

Rexx – Environment ”; Previous Next Before you can start working on Rexx, you need to ensure that you have a fully functional version of Rexx running on your system. This chapter will explain the installation of Rexx and its subsequent configuration on a Windows machine to get started with Rexx. Ensure the following System requirements are met before proceeding with the installation. System Requirements Memory 2 GB RAM (recommended) Disk Space No minimum requirement. Preferably to have enough storage to store the programs which will be created using Rexx. Operating System Version Rexx can be installed on Windows, Ubuntu/Debian, Mac OS X. Downloading Rexx To download Rexx, you should use the following URL − https://www.oorexx.org/download.html This page has a variety of downloads for various versions of Rexx as shown in the following screenshot. Click on the ‘ooRexx install files’ in the table with the header of Release 4.2.0. After this, you will be re-directed to the following page. Click on the ooRexx-4.2.0.windows.x86_64.exe to download the 64-bit version of the software. We will discuss regarding the installation of the software in the following chapter. Print Page Previous Next Advertisements ”;