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

read

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

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

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

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

    Пример использования
    <?php
    // Scenario: Read all text from an ODT document and display a preview
    
    $xhe_host = getenv("RPABOT_HOST_URL");
    
    // подключим функциональные объекты, если еще не подключен
    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()
    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        
    =============================================
    если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум
    .