(SOLVED) - SAVE from menu and as HTML file format?

I want the end user to be able to SAVE document as HTML file to their desired location from the menu…

I added SAVE in the menu with Macros.macroexportfile as the ‘Execute this script fucntion:’ and I get Runtime Error (at 11:89): Out of Global Vars range…

I know the function is in my Macros file, my macros file is included, it appears there are some parameters I’m missing in the actual function call??

Thanks in advance…

On a side note: I just downloaded the Demo of this software and you guys have done an outstanding job!!!.. hats off to the developers… Keep up the good work… I love this application…


Thank you for your kind words.
If I understood, you want to export the currently-displayed HTML file to an external HTML file? Or is it HTML code generated by some PHP code?

Thank you for your reply…

I have PHP generated HTML… two issues:

  1. The HTML that is being generated by the PHP scripts become one huge long single HTML page in the Main Window. This page has images that are nothing more than <img src=> links to files on the End User’s local PC. I need to have the PHP “count” and then “SAVE” every 25 or so images to a separate HTML page. These pages will be stored in HEPubTempPath of course. I then need the PHP to dynamically create the HTML page names and the proper FORWARD and BACK buttons to the newly created HTML pages, which of course are all located in the HEPubTempPath.

  2. I just need on the MENU a SAVE option so the End User can save the huge long single HTML page locally somewhere for future reference. Again, this HTML is dynamically created with my PHP scripts in the Main Window.

I will be purchasing a license key this week for your software… again… my client is very pleased with your application and I’ve been working with your Demo for a few days to try and show them what we can do with it… thanks again for a wonderful product. :stuck_out_tongue:

Since your PHP generates the entire HTML page, I believe that you need a Save As dialog box, in order to retrieve the path to the HTML file the user wants to make.
With HEScript, you can do this:

add an HEScript function similar to this (to the UserMain script):

function SaveDlgFile: String;
// Asks for filename
Result := SaveFileDialog("Save Text As", "*.htm", "*.htm", "HTML Files (*.htm)|*.htm|All files (*.*)|*.*", "");
// Returns blank string if user cancels the dialog.

Then in your PHP code:

echo "Asking for filename...<br>";  

// Executes HEScript to call the system dialog "Save As"...
$filename = exo_return_hescriptcom("UserMain.SaveDlgFile", "Error");   

echo "Filename: ".$filename;  

if (empty($filename))   
 echo "Operation cancelled<br>";

.... Do the processing ....

For the Save command, use the Menu editor: add a menu item which links to the PHP script that calls the Save As dialog and that generates the HTML file.

Thanks for your advice… I have tried many different ways and I still get these two issues:

  1. The SAVE option from the menu does prompt me for a SAVE AS dialog box, but then once you try to save it, I get a Runtime Error (at 1:194): Out of Global Vars range error. (yes… I do have the FUNCTION in the UserMain script)

  2. When I include the SAVE AS option in the PHP, I also get a SAVE AS dialog box, but the file never gets saved, the code does return the correct $filename variable in the echo statement, but no saved file to be found…

Side note: I also noticed if I do a MacroExportFile call from a menu option, it also returns a Out of Global Vars range…?

Thanks again for your help, I’m just trying to show my clients a simple SAVE AS .html format from the main window…


I’m getting closer…

Issue is exo_needcompanionfile() - I’m including my HTML logo images in the .exe build in a folder called iart

How can I use the exo_needcompanionfile() command correctly to copy my images that are in the iart folder to the users Temp/folder so my HTML pages that are being created there can use the path for the images?

I’m finally able to create a HTML page in the users Temp folder from the php scripts using this code:


$content = '<html><body>bla bla bla<img src="iart/logo.jpg"></body></html>';  

$storagelocation = exo_getglobalvariable('HEPubTempPath', '');
$file = 'test.html';
$filename = $storagelocation."$file";  

$fp = fopen($filename,'wb');
			echo 'Unable to create output file: '.$filename;
			fwrite($fp, $content);

But I can not copy my logos, etc to the Temp directory…

I have this as my exo_needcompanionfile call for one of the logos:

exo_needcompanionfile ('iart\\logo.jpg', '', '');

I have read the HELP for this function extensively, but a real world example would be greatly appreciated:


Unpacks a companion file to the Internet Explorer cache, so that plug-ins such as the Flash Player can load it.

Especially useful for image, video and other data files that may be required by Flash movies. See the general demonstration for a sample.

Unpacked files are removed when the application closes.

$source is the virtual path to the companion file that should be unpacked.

$destURLincache is optional. If you leave it blank, ExeOutput for PHP automatically creates the destination URL based on the virtual path. For instance, http://heserver/icon1.png

$isvirtual indicates whether the file should be unpacked to memory (true) or the hard disk (false). Of course, the size of the file shouldn’t exceed the virtual storage’s capacity defined in ExeOutput for PHP.

The function returns the absolute path to the virtual or real file, if successful. Otherwise, a blank value is returned.

Your HELP example is very hard to understand: string exo_needcompanionfile(string $source, string $destURLincache, bool $isvirtual);

Thanks in advance… I’m making progress on this…!!


In your case, exo_needcompanionfile is not the ideal function.
I would use an HEScript code again which uses function UnpackTemporaryResource(const SourceName: String): String;
This function extracts a file from the application’s data (it must have been compiled) to a temporary file and returns the path to this file. The file is normally removed when the application closes. See http://www.exeoutput.com/help/scriptreference.htm

So you write an HEScript that calls UnpackTemporaryResource to unpack the file to the temporary location of HTMLExe. You call that HEScript from PHP: you can then open the file with PHP and copy it to the Temp folder where you create your HTML page.

Correct me if I’m wrong… but if I want to unpack a file called logo.jpg that is in my compiled .exe, in the root folder, then in my HEScript I have:

function UnpackTemporaryResource(const SourceName: String): String;

Then I call this in my PHP like this?:

exo_runhescriptcom ("UserMain.UnpackTemporaryResource", "logo.jpg");  

This does not work for me… I must be missing something in the HEScript for the function UnpackTemporaryResource…??


Got it!!! Instead of using HESscript - (UnpackTemporaryResource) to copy the logo.jpg I ended up using straight PHP:


$storagelocation = exo_getglobalvariable('HEPubTempPath', '');  

$lfile = 'logo.jpg';
$filename = $storagelocation."\\$lfile";
copy($lfile, $filename);  


This works perfectly… I’m able to copy any files I need from the compiled folder to the users temporary location…

Now I’m working on automatically saving multiple HTML pages by certain number of images per page using straight PHP in the same directory… :stuck_out_tongue:

I’ll keep you posted…

Thanks again…

Yes, you have found a faster way. Thanks for sharing.

I know this is very old topic, but exactly what I am looking for. Need to allow students to save simple HTML edits. You care to share what you have accomplished so far?


You are building some CMS?

No CMS. Simple software that students use to create printable posters.

First you should have an HTML editor in your application such as https://www.tinymce.com/ or CKEditor

Thanks. Understand need an editor and use a simple “inline editor” without very many active functions. Children in the age group 8-12 are button pushers so basically all they can edit are font size, color and alignment. Only other function really need is adding an image.

I will continue my search for a solution.

AFAIK some editors let you choose which format tools/buttons you want. This should help you for your problem.