humanemulator.net — справка. Продукт, демо и покупка — на хуманэмулятор.рф | Демо | Купить | API | лог изменений

read

read($path); - Прочитать весь текст

Функция на вход принимает параметры:

  • $path – Путь к файлу

    После выполнения функции возвращаемое значение будет равно одному из двух :
  • результат – Текст или пустое значение если произошла ошибка
  • пусто / null – ошибка

    Пример использования
    <?php
    // Scenario: Read all text from an ODT document and display a preview
    
    $xhe_host = "localhost:7010";
    
    // подключим функциональные объекты, если еще не подключен
    if (!isset($path)) {
        $path = "../../../Templates/init.php";
        require($path);
    }
    
    // начало
    echo "\n<span >libreOffice->".basename (__FILE__)."</span>\n";
    
    // Example 1: ODT file path
    $filePath = "test/test_style.odt";
    
    // Example 1: Get all text from the ODT file
    echo("\n1: Get all text from the ODT file '$filePath':");
    $text = SYSTEM::$libreOffice->read($filePath);
    
    if ($text){
    	// Example 1: Display first 200 symbols of ODT doc
    	echo("\nFirst 100 symbols of ODT doc: ");
    	
        // Example 1: Extract substring arguments to variables
        $startPos = 0;
        $length = 200;
        $textStr = substr($text, $startPos, $length);
        echo("\n$textStr");
    }
    else
    {
        // Example 1: Error message
        echo("\nError when reading text.");
    }
    
    echo("\n\n");
    
    // Quit
    WINDOW::$app->quit();
    ?>
    import sys
    sys.path.insert(0, '../../../Templates PY/')
    
    xhe_host = "127.0.0.1:7013"
    from xweb_human_emulator import libreOffice, app, echo
    
    # начало
    echo("\n<font color=blue>libreOffice->read</font>\n")
    
    # ODT file path
    filePath = "test/test_style.odt"
    
    # Example 1: Get all text from the ODT file
    echo("\n1: Get all text from the ODT file 'filePath': ")
    text = libreOffice.read(filePath)
    
    if text:
    	echo("\nFirst 100 symbols of ODT doc: ")
    	textStr = text[:100]
    	echo("\n" + textStr )
    else:
        echo("\nError when reading text.")
    
    echo("\n\n")
    
    # 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>libreoffice.read</font><hr>");
    
    			// 1 шаг
    			echo("1. Вызовем метод read : ");
    			dynamic result = libreoffice.read("path");
    			echo(result+"\n\n");
    
    			// конец
    			echo("\n\n");
    
    			app.quit();            
    	  }
    }
    xhe_host = "127.0.0.1:7013";
    
    // подключим функциональные объекты, если еще не подключен
    require("../../../Templates JS/init.js");
    
    // начало
    echo("\n<font color=blue>libreOffice->read</font>\n");
    
    // ODT file path
    filePath = "test/test_style.odt";
    
    // Example 1: Get all text from the ODT file
    echo("\n1: Get all text from the ODT file 'filePath': ");
    text = libreOffice.read(filePath);
    
    if (text){
    	echo("\nFirst 100 symbols of ODT doc: ");
        textStr = text.substring(0, 200);
        echo("\n" + textStr );
    }
    else
    {
        echo("\nError when reading text.");
    }
    
    echo("\n\n");
    
    // Quit
    app.quit();

    =============================================
    libreoffice    Объекты    DOM  System  Vision  Web  Window        
    =============================================
    если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум
    .