Rexx find the calling program name

See Net. Data Reference Guide for more information about using the built-in functions. The flat file interface FFI is available on some platforms to let you use flat files or plain-text files as your data source.

Data supports your existing Java applications with the Java language environment. Data macro, or it executes external PERL scripts stored in separate files. So, for instance, replacing those three lines with. Type in and run the following:. If you're going to convince me that REXX compound variables are the same as arrays in C or Pascal, you'll have to explain how the program above works. Any volunteers? Try the program below:. Okay, now run this program.

Enter "The quick brown fox jumps over the lazy dog".

Program name - Rosetta Code

Your computer will tell you each word that appeared in the line of text, and how many times each word appeared. First, there is the line "count. So, after this line, the variables count. Also, you can use the DROP instruction on a stem variable to return all those compound variables to their initial state. Second: Loosely speaking, we're turning count.

But what are the indexes? The REXX function "words" returns the number of blank-delimited words in a string, and "word str, j " returns the j-th such word in str. So w is a word -- and the indexes on count are the actual words that appear in the string! So, for instance, count. Your computer will say hello to you.

Okay, this isn't very earth-shattering. But I want to draw your attention to the third line of the program: "parse pull name". This is the line that accepts input from the keyboard. Okay, so nothing happened. Get a directory, clear the screen, and do some other housekeeping tasks. REXX's external data queue can be used to communicate between far-flung programs, and it isn't affected by any intervening non-REXX programs. So, one quick way to flush the queue would be.

Playing with Rexx on the mainframe - M49

If you want to see what you're flushing, insert a "say dummy" line after the parse pull line. Let's analyze the second line in detail. In this case, you used a parse template of "i j k", which means to put the first word from the argument string into i, put the second word into j, and put the rest into k.

Navigation menu

As in comp3. If this program is passed more than three words as in our example , the extras all become part of k. Try entering "temp1 hello world" to see the latter rule in action. But wait, there's more! Add the following two lines to the end of temp1. So if you "change your mind" about what values should go where, or if you want to use the values in several different ways, you can do it easily. But wait, there's still more! Suppose you're only interested in the first and third words given to your program.

You can use a period as a placeholder in the template. Add the following lines to temp The top line means, "Put the first word in w1, discard the second word, put the third word in w3, and discard the rest of the line. Try it to check if you're right. Try adding these lines to your now quite large!

Note the spelling of "Alfa". You will be told that c1 is "Alfa" and c5 is " Brav". This new PARSE ARG line means "Put the characters in columns into the variable c1, put the characters in columns into the variable c5, and discard the characters from column 10 on if any. Try predicting what would happen if you put an extra space in front of the word "Alfa" when you execute temp1 with the same arguments again, and try it to see if your prediction was correct.

Write an assembler program that is called by REXX

Have we exhausted the possibilities of the parse template? It is however quite easy to write external functions yourself, and this technical tip describes how you might implement a simple 'sort' function. The Rexx interpreter uses 'stem' variables to provide a method to create a collection of related variables. A 'stem' variable consists of a basic name followed by a period and then the reference for the specific variable requested. The stem and the period alone refer to the whole item and allow the entire collection to be initialised to a common value.

By convention simple arrays of variables are referred to using the index We will use this common convention for our sort function and expect to be passed the name of the stem of the variables to sort - in this case 'capital'. However we must do a little work in the Rexx command file before we can use an external function - we must tell the interpreter the name of the function and where to go to find it. So the Rexx command to load this external function is.

Once loaded the function is just called in exactly the same way as any of the intrinsic Rexx functions, for example:. So it is time to look at the C code you need to write! The RexxSAA. For simplicity the example code uses the C convention. Beware - if you miss out the 'RexxFunctionHandler' line the compiler won't complain The Name tells you what name the function was given by Rexx can be useful for multiple functions using the same entry point. Argc and Argv are Rexx-like equivalents to the standard C argument vector - except there is no entry for the program name.

Rexx functions in general support variable numbers of parameters with sensible defaults for the absent parameters, so try and write your own functions the same way. QueueName tells you the name of the current Rexx queue - which we shall ignore for now as the use of Rexx queues is outside the scope of this article. If the external function succeeds it returns 0.