humanemulator.net — справка.
Продукт, демо и покупка — на
хуманэмулятор.рф
|
Демо
|
Купить
|
API
|
лог изменений
delete_line_from_file
delete_line_from_file($file,$line,$timeout=COMMAND_TIME); - удалить заданную строку в файле, доступна с версии 7.0.4Функция на вход принимает параметры:
После отработки функция возвращает результат своей работы в скрипт :
Пример использования
<?php // Scenario: Delete a specific line from a file $xhe_host = "localhost:7010"; // Connect functional objects if not already connected if (!isset($path)){ $path = "../../../Templates/init.php"; require($path); } // info echo "\n<span >textfile->" . basename (__FILE__) . "</span>\n"; // Prepare files // Set file path $filePath = "test/test_delete.txt"; // Set source file for copying $sourceFile = "test/test_dedupe.txt"; // Delete file if it exists echo("Delete file if it exists: $filePath\n"); SYSTEM::$file_os->delete($filePath); // Copy file echo("Copy file from $sourceFile to $filePath\n"); SYSTEM::$file_os->copy($sourceFile, $filePath); // Example 1: Get number of lines in file echo("1. Get number of lines in file: "); $linesCount = SYSTEM::$textfile->get_lines_count($filePath); echo($linesCount . "\n"); // Example 2: Delete line from file // Set line number to delete (0-based) $lineNumber = 2; echo("2. Delete line from file (line number: $lineNumber): "); $result = SYSTEM::$textfile->delete_line_from_file($filePath, $lineNumber); if ($result) { echo("true\n"); } else { echo("false\n"); } // Example 3: Get number of lines in file after deletion echo("3. Get number of lines in file after deletion: "); $linesCountAfter = SYSTEM::$textfile->get_lines_count($filePath); echo($linesCountAfter . "\n"); // End echo "\n"; // Quit the application WINDOW::$app->quit(); ?>
# Additional paths import sys sys.path.insert(0, '../../../Templates PY/') xhe_host = "127.0.0.1:7016" from xweb_human_emulator import * # начало echo("<hr><font color=blue>textfile.xxxxxxxxx</font><hr>") # подготовим файлы path="test\\test_delete.txt"; file_os.delete(path); file_os.copy("test\\test_dedupe.txt",path); # 1 echo("1. Получить число строк в файле : "); echo(textfile.get_lines_count(path),"\n"); # 2 echo("2. Удалить строку из файла : "); echo(textfile.delete_line_from_file(path,2),"\n"); # 3 echo("3. Получить число строк в файле : "); echo(textfile.get_lines_count(path),"\n"); # конец echo("<hr><br>") # Quit app.quit()
#region using using System; using System.Diagnostics; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using System.Threading; using XHE; using XHE.XHE_DOM; using XHE.XHE_System; using XHE.XHE_Window; using XHE.XHE_Web; #endregion class Program:XHEScript { static void Main(string[] args) { // init XHE server = "localhost:7010"; InitXHE(); // начало echo("<hr><font color=blue>textfile.get_all_external_inner_texts_and_hrefs</font><hr>"); // подготовим файлы string path="test\\test_delete.txt"; file_os.delete(path); file_os.copy("test\\test_dedupe.txt",path); // 1 echo("1. Получить число строк в файле : "); echo(textfile.get_lines_count(path)+"\n"); // 2 echo("2. Удалить строку из файла : "); echo(textfile.delete_line_from_file(path,2)+"\n"); // 3 echo("3. Получить число строк в файле : "); echo(textfile.get_lines_count(path)+"\n"); // конец echo("\n\n"); app.quit(); } }
// подключим функциональные объекты, если еще не подключен xhe_host="127.0.0.1:7016"; echo=require("../../../Templates JS/init.js"); // начало echo("<hr><font color=blue>textfile.get_line_from_file</font><hr>"); // подготовим файлы var path="test\\test_delete.txt"; file_os.delete(path); file_os.copy("test\\test_dedupe.txt",path); // 1 echo("1. Получить число строк в файле : "); echo(textfile.get_lines_count(path)+"\n"); // 2 echo("2. Удалить строку из файла : "); echo(textfile.delete_line_from_file(path,2)+"\n"); // 3 echo("3. Получить число строк в файле : "); echo(textfile.get_lines_count(path)+"\n"); // конец echo("\n"); // Quit app.quit();
=============================================
Textfile Объекты DOM System Vision Web Window
=============================================
если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум
.