
- Rexx Tutorial
- Rexx - Home
- Rexx - Overview
- Rexx - Environment
- Rexx - Installation
- Rexx - Installation of Plugin-Ins
- Rexx - Basic Syntax
- Rexx - Datatypes
- Rexx - Variables
- Rexx - Operators
- Rexx - Arrays
- Rexx - Loops
- Rexx - Decision Making
- Rexx - Numbers
- Rexx - Strings
- Rexx - Functions
- Rexx - Stacks
- Rexx - File I/O
- Rexx - Functions For Files
- Rexx - Subroutines
- Rexx - Built-In Functions
- Rexx - System Commands
- Rexx - XML
- Rexx - Regina
- Rexx - Parsing
- Rexx - Signals
- Rexx - Debugging
- Rexx - Error Handling
- Rexx - Object Oriented
- Rexx - Portability
- Rexx - Extended Functions
- Rexx - Instructions
- Rexx - Implementations
- Rexx - Netrexx
- Rexx - Brexx
- Rexx - Databases
- Handheld & Embedded
- Rexx - Performance
- Rexx - Best Programming Practices
- Rexx - Graphical User Interface
- Rexx - Reginald
- Rexx - Web Programming
- Rexx Useful Resources
- Rexx - Quick Guide
- Rexx - Useful Resources
- Rexx - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Rexx - Lines
This function returns either the value 1 or the number of lines left to read in an input stream. The filename is given as the input to the function.
Syntax
lines(filename)
Parameters
filename − This is the name of the file.
Return Value
This function returns either the value 1 or the number of lines left to read in an input stream.
Example
/* Main program */ do while lines(Example.txt) > 0 line_str = linein(Example.txt) say line_str end
In the above program the following things need to be noted.
The lines function reads the Example.txt file.
The while function is used to check if further lines exist in the Example.txt file.
For each line read from the file, the line_str variable holds the value of the current line. This is then sent to the console as output.
Output − When we run the above program, we will get the following result.
Example1 Example2 Example3
There is another variation of the lines command which is as follows −
Syntax
lines(filename,C)
Parameters
filename − This is the name of the file.
C − This is a constant value provided to the function. This value which specifies the number of lines left to read from the file.
Return Value
The return value is the count of lines that are left to be read from the file.
Example
/* Main program */ count = lines(Example.txt,C) say count line_str = linein(Example.txt) say line_str count = lines(Example.txt,C) say count
When we run the above program we will get the following result.
Output
3 Example1 2