- Rexx 教程
- Rexx - 首頁
- Rexx - 概述
- Rexx - 環境
- Rexx - 安裝
- Rexx - 外掛安裝
- Rexx - 基本語法
- Rexx - 資料型別
- Rexx - 變數
- Rexx - 運算子
- Rexx - 陣列
- Rexx - 迴圈
- Rexx - 決策
- Rexx - 數字
- Rexx - 字串
- Rexx - 函式
- Rexx - 棧
- Rexx - 檔案 I/O
- Rexx - 檔案函式
- Rexx - 子程式
- Rexx - 內建函式
- Rexx - 系統命令
- Rexx - XML
- Rexx - Regina
- Rexx - 解析
- Rexx - 訊號
- Rexx - 除錯
- Rexx - 錯誤處理
- Rexx - 面向物件
- Rexx - 可移植性
- Rexx - 擴充套件函式
- Rexx - 指令
- Rexx - 實現
- Rexx - Netrexx
- Rexx - Brexx
- Rexx - 資料庫
- 手持式和嵌入式
- Rexx - 效能
- Rexx - 最佳程式設計實踐
- Rexx - 圖形使用者介面
- Rexx - Reginald
- Rexx - Web 程式設計
- Rexx 有用資源
- Rexx - 快速指南
- Rexx - 有用資源
- Rexx - 討論
Rexx - 行數
此函式返回 1 或輸入流中剩餘的行數。檔名作為函式的輸入給出。
語法
lines(filename)
引數
filename − 這是檔名。
返回值
此函式返回 1 或輸入流中剩餘的行數。
示例
/* Main program */ do while lines(Example.txt) > 0 line_str = linein(Example.txt) say line_str end
在上面的程式中,需要注意以下幾點。
lines 函式讀取 Example.txt 檔案。
while 函式用於檢查 Example.txt 檔案中是否存在更多行。
對於從檔案中讀取的每一行,line_str 變數都儲存當前行的值。然後將其傳送到控制檯作為輸出。
輸出 − 當我們執行上述程式時,我們將得到以下結果。
Example1 Example2 Example3
lines 命令還有另一種變體,如下所示:
語法
lines(filename,C)
引數
filename − 這是檔名。
C − 這是提供給函式的常數值。此值指定要從檔案中讀取的剩餘行數。
返回值
返回值是從檔案中剩餘要讀取的行數。
示例
/* Main program */ count = lines(Example.txt,C) say count line_str = linein(Example.txt) say line_str count = lines(Example.txt,C) say count
當我們執行上述程式時,我們將得到以下結果。
輸出
3 Example1 2
rexx_functions_for_files.htm
廣告