=== modified file 'rules/convert/language_statements.rules'
--- rules/convert/language_statements.rules	2019-09-03 17:36:26 +0000
+++ rules/convert/language_statements.rules	2019-11-01 21:44:23 +0000
@@ -862,6 +862,16 @@
          </action>
       </rule>
       
+      <rule>type == prog.kw_not_embeded and 
+            parent.type == prog.kw_openmime
+         <action>createJavaAst(java.bool_true, "false", closestPeerId)</action>
+      </rule>
+      
+      <rule>type == prog.kw_del_s_c and 
+            parent.type == prog.kw_openmime
+         <action>createJavaAst(java.bool_true, "true", closestPeerId, 0)</action>
+      </rule>
+      
       <rule>type == prog.create_timer and parent.type == prog.statement
          <action>
             createPeerAst(java.static_method_call, "PSTimer.create", closestPeerId)

=== modified file 'src/com/goldencode/p2j/uast/progress.g'
--- src/com/goldencode/p2j/uast/progress.g	2019-09-12 14:35:21 +0000
+++ src/com/goldencode/p2j/uast/progress.g	2019-11-01 21:46:23 +0000
@@ -3586,6 +3586,7 @@
       KW_DEL_NODE;
       KW_DEL_PROC;
       KW_DEL_R_L;
+      KW_DEL_S_C; // FWD extension
       KW_DEL_S_R;
       KW_DEL_S_RS;
       KW_DEL_WORD;
@@ -3639,6 +3640,7 @@
       KW_EDIT_TAB;
       KW_EH_FL;    // FWD extension, not real 4GL!
       KW_EH_SR;    // FWD extension, not real 4GL!
+      KW_NOT_EMBEDED;  // FWD extension
       KW_EMPTY;
       KW_EMPTY_DS;
       KW_EMPTY_SN;
@@ -7962,6 +7964,7 @@
       attrsAndMethods.put( KW_DEL_LINE, METH_LOGICAL );
       attrsAndMethods.put( KW_DEL_NODE, METH_LOGICAL );
       attrsAndMethods.put( KW_DEL_R_L , METH_LOGICAL );
+      attrsAndMethods.put( KW_DEL_S_C , ATTR_LOGICAL ); // FWD extension
       attrsAndMethods.put( KW_DEL_S_R , METH_LOGICAL );
       attrsAndMethods.put( KW_DEL_S_RS, METH_LOGICAL );
       attrsAndMethods.put( KW_DELETE  , METH_LOGICAL );
@@ -8002,6 +8005,7 @@
       attrsAndMethods.put( KW_EDIT_UND, METH_LOGICAL );
       attrsAndMethods.put( KW_EH_FL,    ATTR_LOGICAL ); // FWD extension, not real 4GL
       attrsAndMethods.put( KW_EH_SR,    ATTR_LOGICAL ); // FWD extension, not real 4GL
+      attrsAndMethods.put( KW_NOT_EMBEDED, ATTR_LOGICAL ); // FWD extension
       attrsAndMethods.put( KW_EMB_FILE, METH_LOGICAL ); // FWD extension, not real 4GL
       attrsAndMethods.put( KW_EMB_URL,  METH_LOGICAL ); // FWD extension, not real 4GL
       attrsAndMethods.put( KW_EMPTY   , ATTR_LOGICAL );
@@ -27473,11 +27477,23 @@
    
 /**
  * Matches the FWD-extension language statement <code>OPEN-MIME-RESOURCE</code> and a mandatory
- * pair of resource mime type character and its url character expression.
+ * pair of resource mime type character and its url character expression. If an optional
+ * <code>DELETE-SOURCE-CONTENT</code> is present, then it forces to delete the original input file
+ * when the transfer is complete.
  */
 open_mime_resource_stmt
    :
-      KW_OPENMIME^ expr expr (expr)? stmt_term
+      KW_OPENMIME^ expr expr
+      ( options { generateAmbigWarnings = false; } 
+         :
+         KW_NOT_EMBEDED
+      )?
+      ( 
+         options { generateAmbigWarnings = false; }
+         :
+         KW_DEL_S_C
+      )
+      stmt_term
    ;
    
 /**
@@ -32715,6 +32731,7 @@
          new Keyword("delete-result-list-entry"       ,  0, KW_DEL_R_L , false),
          new Keyword("delete-selected-row"            ,  0, KW_DEL_S_R , false),
          new Keyword("delete-selected-rows"           ,  0, KW_DEL_S_RS, false),
+         new Keyword("delete-source-content"          ,  0, KW_DEL_S_C , false),  // FWD extension
          new Keyword("delete-word"                    ,  0, KW_DEL_WORD, false),  // missing in keyword index, found in prog handbook as a key function
          new Keyword("descending"                     ,  4, KW_DESCEND , true ),  // handles "separate keyword" desc too
          new Keyword("description"                    ,  0, KW_DESCR   , false),  // missing in keyword index, found in customer code
@@ -32787,6 +32804,7 @@
          new Keyword("else"                           ,  0, KW_ELSE    , true ),
          new Keyword("embed-image-by-file"            ,  0, KW_EMB_FILE, false),  // FWD extension, not a real 4GL keyword
          new Keyword("embed-image-by-url"             ,  0, KW_EMB_URL , false),  // FWD extension, not a real 4GL keyword
+         new Keyword("not-embeded-content"            ,  0, KW_NOT_EMBEDED, false),  // FWD extension
          new Keyword("empty"                          ,  0, KW_EMPTY   , false),
          new Keyword("empty-dataset"                  ,  0, KW_EMPTY_DS, false),  // missing from keyword index and UNTESTED at this time
          new Keyword("empty-selection"                ,  0, KW_EMPTY_SN, false),  // missing in keyword index, found elsewhere in lang ref

=== modified file 'src/com/goldencode/p2j/ui/ClientExports.java'
--- src/com/goldencode/p2j/ui/ClientExports.java	2019-10-03 01:18:23 +0000
+++ src/com/goldencode/p2j/ui/ClientExports.java	2019-11-01 08:22:13 +0000
@@ -3122,6 +3122,9 @@
    /**
     * Opens the specified resource in a browser's window.
     * 
+    * @param    deleteContent
+    *           Indicates if the source content will be deleted after the document is loaded by
+    *           the client.
     * @param    mimeType
     *           The resource mime type.
     * @param    path
@@ -3129,11 +3132,17 @@
     * @param    embedded
     *           The document is embedded in the template document.
     */
-   public void openMimeResource(String mimeType, String path, boolean embedded);
+   public void openMimeResource(boolean deletedContent,
+                                String  mimeType,
+                                String  path,
+                                boolean embedded);
 
    /**
     * Opens the specified file resource in a browser's window.
     * 
+    * @param    deleteContent
+    *           Indicates if the source content will be deleted after the document is loaded by
+    *           the client.
     * @param    filePath
     *           The file system path on the legacy system or the host system. If the legacy system
     *           path is given, then it is resolved to the host system path.
@@ -3142,7 +3151,10 @@
     * @param    preferredMimeTypes
     *           The preferred resource mime types.
     */
-   public void openMimeResource(String filePath, boolean embedded, List<String> preferredMimeTypes);
+   public void openMimeResource(boolean      deletedContent,
+                                String       filePath,
+                                boolean      embedded,
+                                List<String> preferredMimeTypes);
 
    /**
     * Set an attribute for a widget implemented at the driver level.  These are custom attributes

=== modified file 'src/com/goldencode/p2j/ui/chui/ThinClient.java'
--- src/com/goldencode/p2j/ui/chui/ThinClient.java	2019-10-03 01:18:23 +0000
+++ src/com/goldencode/p2j/ui/chui/ThinClient.java	2019-11-01 08:29:28 +0000
@@ -23021,6 +23021,9 @@
    /**
     * Opens the specified resource in a browser's window.
     * 
+    * @param    deleteContent
+    *           Indicates if the source content will be deleted after the document is loaded by
+    *           the client.
     * @param    mimeType
     *           The resource mime type.
     * @param    urlString
@@ -23029,12 +23032,15 @@
     *           The document is embedded in the template document.
     */
    @Override
-   public void openMimeResource(String mimeType, String urlString, boolean embedded)
+   public void openMimeResource(boolean deleteContent,
+                                String  mimeType,
+                                String  urlString,
+                                boolean embedded)
    {
       urlString = UiUtils.resolveResourceUrl(urlString);
       try
       {
-         tk.getInstanceDriver().openMimeResource(mimeType, urlString, embedded);
+         tk.getInstanceDriver().openMimeResource(deleteContent, mimeType, urlString, embedded);
       }
       catch (MalformedURLException e)
       {
@@ -23045,6 +23051,9 @@
    /**
     * Opens the specified file resource in a browser's window.
     * 
+    * @param    deleteContent
+    *           Indicates if the source content will be deleted after the document is loaded by
+    *           the client.
     * @param    filePath
     *           The file system path on the legacy system or the host system. If the legacy system
     *           path is given, then it is resolved to the host system path.
@@ -23053,7 +23062,10 @@
     * @param    preferredMimeTypes
     *           The preferred resource mime types.
     */
-   public void openMimeResource(String filePath, boolean embedded, List<String> preferredMimeTypes)
+   public void openMimeResource(boolean      deleteContent,
+                                String       filePath,
+                                boolean      embedded,
+                                List<String> preferredMimeTypes)
    {
       // getting FSD instance
       FileSystemDaemon fsd = getFileSystemDaemon();
@@ -23070,13 +23082,13 @@
             
             if (mimeType != null && preferredMimeTypes.contains(mimeType))
             {
-               openMimeResource(mimeType, "file:///" + fName, embedded);
+               openMimeResource(deleteContent, mimeType, "file:///" + fName, embedded);
             }
             else
             {
                mimeType = preferredMimeTypes.get(0); // takes the default mime type
                
-               openMimeResource(mimeType, "file:///" + fName, embedded);
+               openMimeResource(deleteContent, mimeType, "file:///" + fName, embedded);
             }
          }
       }

=== modified file 'src/com/goldencode/p2j/ui/client/driver/ScreenDriver.java'
--- src/com/goldencode/p2j/ui/client/driver/ScreenDriver.java	2019-09-25 06:28:38 +0000
+++ src/com/goldencode/p2j/ui/client/driver/ScreenDriver.java	2019-11-01 08:27:16 +0000
@@ -405,6 +405,9 @@
    /**
     * Opens the specified resource in a browser's window.
     * 
+    * @param    deleteContent
+    *           Indicates if the source content will be deleted after the document is loaded by
+    *           the client.
     * @param    mimeType
     *           The resource mime type.
     * @param    urlString
@@ -415,7 +418,10 @@
     * @throws   MalformedURLException
     *           If the string presentation of the target resource url is malformed. 
     */
-   public default void openMimeResource(String mimeType, String urlString, boolean embedded)
+   public default void openMimeResource(boolean deleteContent,
+                                        String  mimeType,
+                                        String  urlString,
+                                        boolean embedded)
    throws MalformedURLException
    {
    // do nothing

=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingGuiDriver.java'
--- src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingGuiDriver.java	2019-09-28 08:50:32 +0000
+++ src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingGuiDriver.java	2019-11-01 21:50:30 +0000
@@ -723,7 +723,10 @@
             consumer.accept(os);
          }
          
-         openMimeResource(format.getMimeType(), outFile.toURI().normalize().toASCIIString(), true);
+         openMimeResource(false,
+                          format.getMimeType(),
+                          outFile.toURI().normalize().toASCIIString(),
+                          true);
       }
       catch (IOException e)
       {
@@ -741,6 +744,9 @@
    /**
     * Opens the specified resource in a browser's window.
     * 
+    * @param    deleteContent
+    *           Indicates if the source content will be deleted after the document is loaded by
+    *           the client.
     * @param    mimeType
     *           The resource mime type.
     * @param    urlString
@@ -752,7 +758,10 @@
     *           If the string presentation of the target resource url is malformed. 
     */
    @Override
-   public void openMimeResource(String mimeType, String urlString, boolean embedded)
+   public void openMimeResource(boolean deleteContent,
+                                String  mimeType,
+                                String  urlString,
+                                boolean embedded)
    throws MalformedURLException
    {
       // test that urlString is well-formed. 
@@ -768,6 +777,13 @@
       {
          throw new MalformedURLException(ex.getMessage());
       }
+      // set file stamp
+      long current = System.currentTimeMillis();
+      File sourceContent = Paths.get(uri).toFile();
+      if (!sourceContent.setLastModified(current))
+      {
+         current = sourceContent.lastModified();
+      }
       
       if (embedded)
       {
@@ -789,6 +805,34 @@
       {
          throw new RuntimeException(ex);
       }
+      
+      long elapsed = 0;
+      
+      long start = System.currentTimeMillis();
+      
+      while(sourceContent.lastModified() == current)
+      {
+         try
+         {
+            Thread.currentThread().sleep(1000);
+         }
+         catch (InterruptedException e)
+         {
+            
+         }
+         
+         elapsed = System.currentTimeMillis() - start;
+         
+         if (elapsed > 60 * 1000)
+         {
+            break;
+         }
+      }
+      
+      if (deleteContent)
+      {
+         sourceContent.delete();
+      }
    }
 
    /**

=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebDriver.java'
--- src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebDriver.java	2019-09-28 08:50:32 +0000
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebDriver.java	2019-11-01 08:46:12 +0000
@@ -212,6 +212,7 @@
 import java.util.*;
 
 import com.goldencode.p2j.ui.client.driver.*;
+
 import org.eclipse.jetty.server.*;
 import org.eclipse.jetty.util.resource.*;
 
@@ -2571,6 +2572,9 @@
    /**
     * Opens the specified resource in a browser's window.
     * 
+    * @param    deleteContent
+    *           Indicates if the source content will be deleted after the document is loaded by
+    *           the client.
     * @param    mimeType
     *           The resource mime type.
     * @param    urlString
@@ -2584,7 +2588,10 @@
     *           For other IO errors during file operations.
     */
    @Override
-   public void openMimeResource(String mimeType, String urlString, boolean embedded)
+   public void openMimeResource(boolean deleteContent,
+                                String  mimeType,
+                                String  urlString,
+                                boolean embedded)
    throws MalformedURLException
    {
       // test that urlString is well-formed. 
@@ -2611,7 +2618,7 @@
          {
             local = true;
             
-            id = resolveResourceId(mimeType, url);
+            id = resolveResourceId(deleteContent, mimeType, url);
          }
       }
       
@@ -2621,33 +2628,55 @@
    /**
     * Resolve the document ID used to retrieve the specified resource.
     * 
+    * @param    deleteContent
+    *           Indicates if the source content will be deleted after the document is loaded by
+    *           the client.
     * @param    mimeType
     *           The resource mime type.
     * @param    url
     *           The resource URL - must be a local resource.
+    * 
+    * @throws   MalformedURLException 
+    *           If the string presentation of the target resource url is malformed. 
     */
-   String resolveResourceId(String mimeType, URL url)
+   String resolveResourceId(boolean deleteContent, String mimeType, URL url)
+   throws MalformedURLException
    {
-      final File temporaryFile;
-      try
+      final File resourceFile;
+      
+      if (deleteContent)
       {
-         temporaryFile = File.createTempFile("openMimeResource",
-                                             null,
-                                             new File(tmpDir));
-         try(InputStream input = url.openStream();
-             FileOutputStream output = new FileOutputStream(temporaryFile))
-         {
-            ByteStreams.copy(input, output);
+         try
+         {
+            resourceFile = Paths.get(url.toURI()).toFile();
+         }
+         catch (URISyntaxException ex)
+         {
+            throw new MalformedURLException(ex.getMessage());
          }
       }
-      catch (IOException ex)
+      else
       {
-         throw new RuntimeException(ex);
+         try
+         {
+            resourceFile = File.createTempFile("openMimeResource",
+                                                null,
+                                                new File(tmpDir));
+            try(InputStream input = url.openStream();
+                FileOutputStream output = new FileOutputStream(resourceFile))
+            {
+               ByteStreams.copy(input, output);
+            }
+         }
+         catch (IOException ex)
+         {
+            throw new RuntimeException(ex);
+         }
       }
       
       Consumer<OutputStream> consumer = output ->
       {
-         try(FileInputStream input = new FileInputStream(temporaryFile))
+         try(FileInputStream input = new FileInputStream(resourceFile))
          {
             ByteStreams.copy(input, output);
          }
@@ -2657,7 +2686,7 @@
          }
       };
       
-      Runnable finalizer = () -> { temporaryFile.delete(); };
+      Runnable finalizer = () -> { resourceFile.delete(); };
       
       UUID uuid = UUID.randomUUID();
       DocumentOutput docOut = new DocumentOutput(consumer,

=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/WebHtmlBrowser.java'
--- src/com/goldencode/p2j/ui/client/gui/driver/web/WebHtmlBrowser.java	2019-09-28 08:50:32 +0000
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/WebHtmlBrowser.java	2019-11-01 19:18:28 +0000
@@ -72,6 +72,7 @@
 import com.goldencode.p2j.ui.chui.ThinClient;
 import com.goldencode.p2j.ui.client.*;
 import com.goldencode.p2j.util.*;
+
 import org.eclipse.jetty.http.*;
 import org.eclipse.jetty.server.*;
 import org.eclipse.jetty.server.handler.*;
@@ -263,7 +264,15 @@
             local = true;
             ThinClient tc = ThinClient.getInstance();
             GuiWebDriver gd = (GuiWebDriver) tc.getOutputManager().getInstanceDriver();
-            id = gd.resolveResourceId(mimeType, url);
+            try
+            {
+               id = gd.resolveResourceId(false, mimeType, url);
+            }
+            catch (MalformedURLException ex)
+            {
+               ex.printStackTrace();
+               return false;
+            }
          }
       }
 

