Setting indicator variables with one operation is easily handled with the present RPG syntax. For example, this:. If type has a value of E, indicator 25 turns on. If not, indicator 25 turns off.
You can do the same thing in CL, by the way. Here is a short program interested professionals can compile and play with. Each test is done twice; the long way comes first, followed by the IIF version. I continually look for ideas for new functions to help me in my work. I hope you like IIF, and if you are not writing your own functions, I hope you will learn to do so soon.
Leave a Reply Cancel reply. Search for:. I had a lot of five-line tests like this:. Something about this looked familiar, and I finally realized what it was. This type of code looked strange to me at the time, since I was used to accomplishing the same task with one COMP operation. Anyway, back to the present. In a few minutes, I had my own IIF function. IIF is a very simple function. It accepts three arguments: a condition, a value to return if the condition is true, and a value to return if the condition is false.
Here is the prototype:. And here is the function itself:. Using IIF, I was able to reduce the many five-line tests to one line each. Notice that my IIF function works with character data only. Exception is issued if the value is less than 1 or greater than the total number of occurrences. A file is considered "open" if it has been opened by the RPG program during initialization or by an OPEN operation, and has not subsequently been closed.
The value is the address of the entry point identified by the argument. The character constant can be a character or hexadecimal literal or constant name that represents a character or hexadecimal literal. When a character constant is used, this identifies the entry point by name. The prototype must a prototype for a bound call. So if the caller is written in another ILE language, it will need to pass an operational descriptor on the call.
Rpg free format programming - مستندات Google
The first parameter must be a basing pointer value. The second parameter must be a non-float numeric value with zero decimal places. The function returns a pointer to the allocated storage. This may be the same as ptr or different. The result has the same sign as the dividend. The first and second parameter must be of type character, graphic, or UCS-2 and can be in either fixed- or variable-length format.
The second parameter must be the same type as the first. The third parameter represents the starting position, measured in characters, for the replacement string. If it is not specified, the starting position is at the beginning of the source string. The value may range from one to the current length of the source string plus one. The fourth parameter represents the number of characters in the source string to be replaced. If zero is specified, then the replacement string is inserted before the specified starting position.
If the parameter is not specified, the number of characters replaced is the same as the length of the replacement string.follow
Free-Format RPG IV -- Chapter 3
The value must be greater than or equal to zero, and less than or equal to the current length of the source string. The starting position and length may be any numeric value or numeric expression with no decimal positions. The returned value is varying length if the source string or replacement string are varying length, or if the start position or source length to replace are variables. Otherwise, the result is fixed length. If the start position is specified, the search begins at the starting position.
The result is always the position in the source string even if the starting position is specified.
- Free-Format RPG IV -- Chapter 3.
- RPG Built In Functions - MidrangeWiki.
- Behalt das Leben lieb: Roman (German Edition).
- Rendering of Souls?
- Fler böcker av Jim Martin.
- RPGLE Split;
The first parameter must be of type character, graphic, or UCS The third parameter, if specified, must be numeric with zero decimal positions. When any parameter is variable in length, the values of the other parameters are checked against the current length, not the maximum length. The type of the return value is unsigned integer.
RPG IV - Built-in Functions through IBM i v6.11
This built-in function can be used anywhere that an unsigned integer expression is valid. Doolittle', if the search starts at position 2. The result is a time or timestamp value with the appropriate number of seconds added or subtracted. The argument may be a literal, a named constant, a data structure, a data structure subfield, a field, an array or a table name. It cannot contain an expression, but some constant-valued built-in functions and constant expressions may be accepted. For a graphic literal, the size is the number of bytes occupied by the graphic characters, not including leading and trailing shift characters.
For a hexadecimal or UCS-2 literal, the size returned is half the number of hexadecimal digits in the literal. If the argument is an array name, table name, or multiple occurrence data structure name, the value returned is the size of one element or occurrence. For a multiple-occurrence data structure containing pointer subfields, the size may be greater than the size of one occurrence times the number of occurrences. The system requires that pointers be placed in storage at addresses evenly divisible by As a result, the length of each occurrence may have to be increased enough to make the length an exact multiple of 16 so that the pointer subfields will be positioned correctly in storage for every occurrence.
If the operand is of type float, the result is of type float; otherwise, the result is packed decimal numeric. If the parameter has a value less than zero, exception is issued. The first parameter must be a basing-pointer variable. The second parameter, if specified, must be a numeric value with zero decimal positions. If not specified, it defaults to The first parameter must point to storage that is at least as long as the length given by the second parameter.
Error conditions: If the length parameter is not between 1 and , an error will occur. If the pointer is not set, an error will occur. If the storage addressed by the pointer is shorter than indicated by the length parameter, either An error will occur Data corruption will occur.
This built-in function can be used anywhere that a character expression is valid. No error will be given at run time if the null terminator is not found within the length specified. In this case, the length of the resulting value is the same as the length specified.
The maximum length that can be specified is This means that at most bytes of the right-hand side can be used, since 1 byte must be reserved for the null-terminator at the end. The length indicates the amount of storage that the pointer points to. This length should be greater than the maximum length the right-hand side will have. The pointer must be set to point to storage at least as long as the length parameter. If the length of the right-hand side of the expression is longer than the specified length, the right-hand side value is truncated. Note: Data corruption will occur if both of the following are true: The length parameter is greater than the actual length of data addressed by the pointer.
The length of the right-hand side is greater than or equal to the actual length of data addressed by the pointer. It returns an unsigned numeric value. The first parameter is the date, time, or timestamp value. The second parameter is the portion that you want to extract. For example, the day portion of February 10 is 10 not This function always returns a 4-digit year, even if the date format has a 2-digit year. It may also be used as the result of an assignment with the EVAL operation code.
The start parameter represents the starting position of the substring. The length parameter represents the length of the substring. If it is not specified, the length is the length of the string parameter less the start value plus one. The string must be character, graphic, or UCS-2data. Starting position and length may be any numeric value or numeric expression with zero decimal positions. The starting position must be greater than zero. The length may be greater than or equal to zero. When the string parameter is varying length, the values of the other parameters are checked against the current length, not the maximum length.
When specified as a parameter for a definition specification keyword, the parameters must be literals or named constants representing literals.