RSpec – Useful Resources ”; Previous Next The following resources contain additional information on RSpec. Please use them to get more in-depth knowledge on this. Python Programming Certification 2024 Most Popular 9 Courses 1 eBooks Tutorialspoint More Detail Artificial Intelligence and Machine Learning Certification 2024 Most Popular 7 Courses 1 eBooks Tutorialspoint More Detail Java Certification 2024 Best Seller 7 Courses 1 eBooks Tutorialspoint More Detail Print Page Previous Next Advertisements ”;
Category: Computer Programming
Rexx – Useful Resources
Rexx – Useful Resources ”; Previous Next The following resources contain additional information on Rexx. Please use them to get more in-depth knowledge on this. Useful Links on Rexx Rexx Programming − Official Home Page Rexx Wiki − Wikipedia Reference for Rexx. Useful Books on Rexx To enlist your site on this page, please drop an email to [email protected] Print Page Previous Next Advertisements ”;
Rexx – Discussion
Discuss Rexx ”; 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. 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. Print Page Previous Next Advertisements ”;
Scala – Basic Syntax
Scala – Basic Syntax ”; Previous Next If you have a good understanding on Java, then it will be very easy for you to learn Scala. The biggest syntactic difference between Scala and Java is that the ”;” line end character is optional. When we consider a Scala program, it can be defined as a collection of objects that communicate via invoking each other’s methods. Let us now briefly look into what do class, object, methods and instance variables mean. Object − Objects have states and behaviors. An object is an instance of a class. Example − A dog has states – color, name, breed as well as behaviors – wagging, barking, and eating. Class − A class can be defined as a template/blueprint that describes the behaviors/states that are related to the class. Methods − A method is basically a behavior. A class can contain many methods. It is in methods where the logics are written, data is manipulated and all the actions are executed. Fields − Each object has its unique set of instance variables, which are called fields. An object”s state is created by the values assigned to these fields. Closure − A closure is a function, whose return value depends on the value of one or more variables declared outside this function. Traits − A trait encapsulates method and field definitions, which can then be reused by mixing them into classes. Traits are used to define object types by specifying the signature of the supported methods. First Scala Program We can execute a Scala program in two modes: one is interactive mode and another is script mode. Interactive Mode Open the command prompt and use the following command to open Scala. >scala If Scala is installed in your system, the following output will be displayed − Welcome to Scala version 2.9.0.1 Type in expressions to have them evaluated. Type :help for more information. Type the following text to the right of the Scala prompt and press the Enter key − scala> println(“Hello, Scala!”); It will produce the following result − Hello, Scala! Script Mode Use the following instructions to write a Scala program in script mode. Open notepad and add the following code into it. Example Live Demo object HelloWorld { /* This is my first java program. * This will print ”Hello World” as the output */ def main(args: Array[String]) { println(“Hello, world!”) // prints Hello World } } Save the file as − HelloWorld.scala. Open the command prompt window and go to the directory where the program file is saved. The ‘scalac’ command is used to compile the Scala program and it will generate a few class files in the current directory. One of them will be called HelloWorld.class. This is a bytecode which will run on Java Virtual Machine (JVM) using ‘scala’ command. Use the following command to compile and execute your Scala program. > scalac HelloWorld.scala > scala HelloWorld Output Hello, World! Basic Syntax The following are the basic syntaxes and coding conventions in Scala programming. Case Sensitivity − Scala is case-sensitive, which means identifier Hello and hello would have different meaning in Scala. Class Names − For all class names, the first letter should be in Upper Case. If several words are used to form a name of the class, each inner word”s first letter should be in Upper Case. Example − class MyFirstScalaClass. Method Names − All method names should start with a Lower Case letter. If multiple words are used to form the name of the method, then each inner word”s first letter should be in Upper Case. Example − def myMethodName() Program File Name − Name of the program file should exactly match the object name. When saving the file you should save it using the object name (Remember Scala is case-sensitive) and append ‘.scala’ to the end of the name. (If the file name and the object name do not match your program will not compile). Example − Assume ”HelloWorld” is the object name. Then the file should be saved as ”HelloWorld.scala”. def main(args: Array[String]) − Scala program processing starts from the main() method which is a mandatory part of every Scala Program. Scala Identifiers All Scala components require names. Names used for objects, classes, variables and methods are called identifiers. A keyword cannot be used as an identifier and identifiers are case-sensitive. Scala supports four types of identifiers. Alphanumeric Identifiers An alphanumeric identifier starts with a letter or an underscore, which can be followed by further letters, digits, or underscores. The ”$” character is a reserved keyword in Scala and should not be used in identifiers. Following are legal alphanumeric identifiers − age, salary, _value, __1_value Following are illegal identifiers − $salary, 123abc, -salary Operator Identifiers An operator identifier consists of one or more operator characters. Operator characters are printable ASCII characters such as +, :, ?, ~ or #. Following are legal operator identifiers − + ++ ::: <?> :> The Scala compiler will internally “mangle” operator identifiers to turn them into legal Java identifiers with embedded $ characters. For instance, the identifier :-> would be represented internally as $colon$minus$greater. Mixed Identifiers A mixed identifier consists of an alphanumeric identifier, which is followed by an underscore and an operator identifier. Following are legal mixed identifiers − unary_+, myvar_= Here, unary_+ used as a method name defines a unary + operator and myvar_= used as method name defines an assignment operator (operator overloading). Literal Identifiers A literal identifier is an arbitrary string enclosed in back ticks (` . . . `). Following are legal literal identifiers − `x` `<clinit>` `yield` Scala Keywords The following list shows the reserved words in Scala. These reserved words may not be used as constant or variable or any other identifier names. abstract case catch class def do else extends false final finally for forSome if implicit import lazy match new Null object override package private protected return sealed super this throw trait Try true type val
RSpec – Helpers
RSpec – Helpers ”; Previous Next Sometimes your RSpec examples need an easy way to share reusable code. The best way to accomplish this is with Helpers. Helpers are basically regular Ruby methods which you share across examples. To illustrate the benefit of using helpers, let’s consider this code − class Dog attr_reader :good_dog, :has_been_walked def initialize(good_or_not) @good_dog = good_or_not @has_been_walked = false end def walk_dog @has_been_walked = true end end describe Dog do it ”should be able to create and walk a good dog” do dog = Dog.new(true) dog.walk_dog expect(dog.good_dog).to be true expect(dog.has_been_walked).to be true end it ”should be able to create and walk a bad dog” do dog = Dog.new(false) dog.walk_dog expect(dog.good_dog).to be false expect(dog.has_been_walked).to be true end end This code is clear, but it’s always a good idea to reduce repeated code whenever possible. We can take the above code and reduce some of this repetition with a helper method called create_and_walk_dog(). class Dog attr_reader :good_dog, :has_been_walked def initialize(good_or_not) @good_dog = good_or_not @has_been_walked = false end def walk_dog @has_been_walked = true end end describe Dog do def create_and_walk_dog(good_or_bad) dog = Dog.new(good_or_bad) dog.walk_dog return dog end it ”should be able to create and walk a good dog” do dog = create_and_walk_dog(true) expect(dog.good_dog).to be true expect(dog.has_been_walked).to be true end it ”should be able to create and walk a bad dog” do dog = create_and_walk_dog(false) expect(dog.good_dog).to be false expect(dog.has_been_walked).to be true end end When you run the above code, you will see this output − .. Finished in 0.002 seconds (files took 0.11401 seconds to load) 2 examples, 0 failures As you can see, we were able to push the logic for creating and walking a dog object into a Helper which allows our examples to be shorter and cleaner. Print Page Previous Next Advertisements ”;
Rexx – Quick Guide
Rexx – Quick Guide ”; Previous Next Rexx – Overview 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 Rexx – Environment 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. Rexx – Installation The following steps will explain in detail how Rexx can be installed on a Windows system. Step 1 − Launch the Installer downloaded in the earlier section. After the installer starts, click on the Run button. Step 2 − Click the next button on the following screen to proceed with the installation. Step 3 − Click on the I Agree button to proceed. Step 4 − Accept the default components and then click on the next button. Step 5 − Choose the installation location and click on the Next button. Step 6 − Accept the default processes which will be installed and click on the Next button. Step 7 − Choose the default file associations and click on the Next button. Step 8 − Click on the check boxes of send Rexx items to the executables and then click on the Next button as shown in the following screenshot. Step 9 − In the next screen, choose the editor for working with Rexx files. Keep the notepad as the default option. Also accept the default extension for each Rexx file. Step 10 − Accept the default settings on the following screen that comes up and click on the Next button to proceed further with the installation. Step 11 − Finally click on the Install button to proceed with the installation. Step 12 − Once the installation is complete, you need to click on the Next button to proceed further. Step 13 − Click on the Finish button to complete the installation. Rexx – Installation of Plugin-Ins In this chapter, we will discuss on how to install plug-ins on popular IDE’s (Integrated Development Environment). Rexx as a programming language is also available in popular IDE’s such as Eclipse. Let’s look at how we can get the required plugin’s in these IDE’s, so that you have more choices in working with Rexx. Installation in Eclipse To make a trouble-free installation of Rexx in Eclipse, you will need to adhere to the following steps. Step 1 − Open Eclipse and click on the Menu item, Help → Eclipse Marketplace as shown in the following screenshot. Step 2 − In the next dialog box, enter Rexx in the search criteria and click on the search button. Once done, click the Install button. Step 3 − Click on the Confirm button to further continue with the features installation. Step 4 − Eclipse will then download the necessary files to start off with the installation. Once done, Eclipse will ask for accepting the license agreements. Click on accepting the license agreements and then click on the Finish button as shown in the following screenshot. Eclipse will then start installing the software in the background. Step 5 − You will probably get a security warning (as shown in the following screenshot). Click on the OK button to proceed. Step 6 − You will be prompted to restart Eclipse once the updates are installed. Click Yes to restart Eclipse. Rexx – Basic Syntax In order to understand the basic syntax of Rexx, let us first look at a simple Hello World
Rexx – Best Programming Practices ”; Previous Next Every programmer wants their program to be the best when it comes to quality and efficiency. The following are some of the best programming practices or hints when writing Rexx programs which can help one achieve these goals. Hint 1 Use the address command before you issue any command to the operating system or command prompt. This will help you get the address space beforehand in memory and cause your program to run more efficiently. An example of the address command is shown below. Example /* Main program */ address system dir The output of the command is as follows, but it could vary from system to system. Volume in drive H is Apps Volume Serial Number is 8E66-AC3D Directory of H: 06/30/2016 01:28 AM <DIR> Apps 07/05/2016 03:40 AM 463 main.class 07/07/2016 01:30 AM 46 main.nrx 07/07/2016 01:42 AM 38 main.rexx 3 File(s) 547 bytes Dir(s) 313,085,173,760 bytes free Hint 2 Ensure all commands to the operating system are in upper case and in quotes wherever possible. An example for the same is shown below. Example /* Main program */ options arexx_bifs say chdir(”REXXML100”) say directory() When we run the above program, we will get the following result. 0 D:rexxxml100 Hint 3 Avoid creating big comment blocks as shown in the following program. Example /******/ /* */ /* */ /* */ /******/ /* Main program */ address system dir Hint 4 Use the Parse statement to assign default values. An example for the same is shown below. Example parse value 0 1 with a, b Hint 5 Use the “Left(var1,2)” statement wherever possible instead of the “substr(var1,1,2)” statement. Hint 6 Use the “Right(var1,2)” statement wherever possible instead of the “substr(var1,length(var1),2)” statement. Print Page Previous Next Advertisements ”;
Rexx – Performance
Rexx – Performance ”; Previous Next One of the key aspects of any programming language is the performance of the application. Special practices need to be taken care of to ensure that the application’s performance is not hampered. Let’s look at some of the considerations described in steps for better understanding − Step 1 − Try to reduce the number of instructions – In Rexx each instruction carries an overhead. So try to reduce the number of instructions in your program. An example of instructions that can be redesigned is shown below. Instead of using multiple if else statements one can use the parse statement. So like in the following program, instead of having an if condition for each value, and getting the value of word1, word2, word3 and word4, use the parse statement. /* Main program */ parse value ”This is a Tutorial” with word1 word2 word3 word4 say “””word1″”” say “””word2″”” say “””word3″”” say “””word4″”” Step 2 − Try to combine multiple statements into one statement. An example is shown below. Suppose if you had the following code which did the assignment for – a and b and passed it to a method called proc. do i = 1 to 100 a = 0 b = 1 call proc a,b end You can easily replace the above given code with the following code using the parse statement. do i = 1 for 100 parse value 0 1 with a, b, call proc a,b end Step 3 − Try to replace the do..to loop with the do..for loop wherever possible. This is normally recommended when the control variable is being iterated through a loop. /* Main program */ do i = 1 to 10 say i end The above program should be replaced by the following program. /* Main program */ do i = 1 for 10 say i end Step 4 − If possible, remove the for condition from a do loop as shown in the following program. If the control variable is not required, then just put the end value in the do loop as shown below. /* Main program */ do 10 say hello end Step 5 − In a select clause, whatever u feel is the best condition which will be evaluated needs to put first in the when clause. So in the following example, if we know that 1 is the most frequent option, we put the when 1 clause as the first clause in the select statement. /* Main program */ select when 1 then say”1” when 2 then say”2” otherwise say ”3” end Print Page Previous Next Advertisements ”;
Rexx – Web Programming
Rexx – Web Programming ”; Previous Next Rexx has the facility to work with web servers as well. The most common being the apache web server. In order to use Rexxw with the Apache web server, you need to first download the Rexx modules from the following link − https://sourceforge.net/projects/modrexx/?source=typ_redirect Once done, make sure to add the mod Rexx modules to the class path. The following lines need to be added and modified to the Apache configuration file. The following lines need to be added to the end of the appropriate − httpd.conf LoadModule list. LoadModule rexx_module modules/mod_rexx.dll The following lines should be added at the end of the http.conf file. AddType application/x-httpd-rexx-script .rex .rexx AddType application/x-httpd-rexx-rsp .rsp Add these for REXX Server Page support RexxRspCompiler “c:/Program Files/Apache Group/Apache2/bin/rspcomp.rex” Once the above changes have been made, you need to shut down and restart your apache web server. The above lines also allow you to have Rexx based server pages just like Java server pages. You can add the Rexx code directly to the html pages. An example is shown below − <p>The current date and time is <?rexx /* Inserting the rexx statement */ say date() time() ?> </p> When a Rexx based server page is run, the following things are carried out − First a temporary file is created. Then the Rexx Server compiler compiles the file into a Rexx program and places it in the temporary file. The next step is to actually run the Rexx program. Finally, the temporary file is removed. Print Page Previous Next Advertisements ”;
Rexx – Reginald
Rexx – Reginald ”; Previous Next Reginald is another Rexx interpreter which was developed by Jeff Glantt and has some customizations on how Rexx programs can be run. In this section, we will see how to get Reginald setup and run a few Rexx programs in it. Environment Setup The first step is the environment setup which is to download the Reginald files. This can be done from the following website link − http://www.manmrk.net/tutorials/rexx/Reginald/win32/rxusrw32.htm Once the download is complete and you launch the installer, the next screen will allow you to choose the install location. Click the Install button to proceed. Once complete, we can now start to run one sample program in the Reginald interpreter. Create a simple program as shown below. /* Main program */ say ”Hello” Then run the following command − RxLaunch.exe main.rexx You will then get the following output. This program will now be running in the Reginald interpreter. Other Functions Available Apart from the normal Rexx commands, Reginald had some specific commands that are tailor-made for the Windows operating system. DriveMap is one such command − DriveMap This function gives information on the drive. Syntax − Drivemap(,options) Parameters − Options − These are a list of keywords which can be used to get various information on the drives of the local computer. Return Value A string value which has information on the drive. Example − /* Main program */ say ”Drives on system : ” DriveMap(,”FIXED”) If the above program is run, you will get the following output. This output depends from system to system. List of disk drives : C: D: Print Page Previous Next Advertisements ”;