How can I read information stored in an external file in javascript?

Use HEScript scripting combined with JavaScript window.external methods, for instance function window.external.GetHEScriptCom(ComLine, DefValue).

First, you need to create a script in HEScript that reads the contents of a text file. See the dedicated How to save/read external text files?

For instance, use this HEScript function in your UserMain script.

uses Classes; // Add this line to the top of your script

function ReadTextFile(Filename: String): String;
var
T: TStringList;
EbookPath: String;
begin
T := TStringList.Create;
EbookPath := GetGlobalVar("HEPublicationPath", "");
// Loads the text file.
T.LoadFromFile(EbookPath + Filename);
// Gets the contents.
Result := T.Text;
T.Free;
end;

Then you can call this directly from JavaScript:

var tex = window.external.GetHEScriptCom('UserMain.ReadTextFile|abc.txt', 'Error while reading file');

imgFrequently Asked Questions

imgSearch and post your questions to the user forum

 


About

This is the online documentation of HTML Executable.

About HTML Executable

HTML Executable is a versatile HTML compiler and ebook compiler: it lets you create secure ebooks and desktop applications with your websites, HTML or PDF documents.

You can easily create attractive ebooks, full-featured HTML applications (RIA) and software, digital publications from your websites, PDF files and HTML documents for online or offline distribution.

Learn more - Free Trial