Web Connection
recompile all PRG pages after global HTML change?
Gravatar is a globally recognized avatar based on your email address. recompile all PRG pages after global HTML change?
  Michael Hogan (Ideate Hosting)
  All
  Dec 22, 2016 @ 11:23am

When I make global html page changes, how can I recompile all the resulting prg files without having to hit each page on my development machine?

At the moment I have most pages included in the exe so I can just upload the exe to the live server. I'm still considering if this is the best option...

Gravatar is a globally recognized avatar based on your email address. re: recompile all PRG pages after global HTML change?
  Rick Strahl
  Michael Hogan (Ideate Hosting)
  Dec 22, 2016 @ 11:27am

What are you doing exactly? Are you talking about Web Control Pages? If so there's unfortunately no real good way to compile all pages unless you explicitly write a routine that does that.

For scripts (ie. ExpandScript()) I recommend you use a mode that provides auto-compilation. I use ScriptMode=1 in app.ini to allow dynamic compilation that checks for file dates. With improvements that were made ~WWC 5.5 overhead for this is minimal.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: recompile all PRG pages after global HTML change?
  Michael Hogan (Ideate Hosting)
  Rick Strahl
  Dec 22, 2016 @ 11:56am

I inherited a Web Control project and I need to make a script change in the header of almost all pages. My scriptmap is .tds

If I understand the 'Deploying Web Control Framework Pages' help file, I can exclude all the *_page.prg files from my project so they are not included in the exe, copy all my *.tds files to the live server, and set the server to parse mode 2 - parse, compile and run.

I'm assuming WC will use the fxp file unless the .tds file is newer - in which case it will create the prg, and then generate the frx?

Does all that make sense?

Of course, if it's slower in this mode, perhaps a better approach would just to do my search and replace in the prg files and keep them included in the exe.

Third option would be to compile all the prg's into frx and include those instead...

Advise, please. Things are already slow (for non-wconnect reasons) so I don't want to make it slower.

Gravatar is a globally recognized avatar based on your email address. re: recompile all PRG pages after global HTML change?
  Rick Strahl
  Michael Hogan (Ideate Hosting)
  Dec 22, 2016 @ 11:14pm

If you use PRG files that are in your project you need to make sure those PRG files are recompiled if there are changes. If you use external PRG files you can ship the PRG files and they will compile in nPageMode 1 and 2. With nPageMode 3 the FXP files or precompiled code has to be present which generally is used with code embedded in the EXE.

There are WebPageParser::ParseFiles() and WebPageParser::ParseToFile() that you can use to pre-compile pages, but this will not automatically capture dependencies like user control etc. This is essentially what wwProcess does internally to deal with Pages (it calls ParseToFile() then executes that file).

There main gotcha with this is that anything that the page code depends on has to be available so the code compiles properly. So you probably have to run any automation from within the project that runs the actual Pages.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: recompile all PRG pages after global HTML change?
  Stein Goering
  Michael Hogan (Ideate Hosting)
  Jan 16, 2017 @ 03:06pm

FWIW, we run with PageParseMode=3. We have a compiler routine built into our main app using the core code shown below:

        lcList = [The following files have been parsed and compiled:<br />]
        lnCount = ADIR(laFiles,Config.cHTMLPAGEPATH+[*]+MapExt)
        FOR i = 1 TO lnCount
          lcFile = laFiles(i,1)
          DO AWPageParser WITH Config.cHTMLPAGEPATH+lcFile,1,.T.
          lcList = lcList + lcFile + [<br />]
        ENDFOR

AWPageParser...

LPARAMETERS lcPhysicalPage, lnParseMode, llSilent  
LOCAL oParser, lcOutput, lcPRG, llError

SET PROCEDURE TO webpageparser.prg ADDITIVE
oParser = CREATEOBJECT("WebPageParser")
oParser.Parsemode = lnParseMode
oParser.SilentCompilation = llSilent
oParser.CompileOutputFile = .T.  

  oParser.ParseFiles(lcPhysicalPage)
  IF oParser.lError
    IF !llSilent
      ShowHtml(oParser.cErrorMsg)
    ELSE
      lcOutput = oParser.cErrorMsg
    ENDIF
  ENDIF

When we post updated templates and/or back-end PRGs, we just run the above to generate new FXPs and we're good to go. The only problem is that some (most?) of our pages have an irritating tendency to fail to unload completely from memory, resulting in xxxxx.fxp File in Use errors. Only recourse is to unload the COM servers, then run the compile routine again before anyone hits the pages.

--stein

Gravatar is a globally recognized avatar based on your email address. re: recompile all PRG pages after global HTML change?
  Rick Strahl
  Stein Goering
  Jan 16, 2017 @ 09:17pm

Stein,

nPageParseMode=3 is tough to deal with admittedly. If everything is in pages than it's no problem but if there are user controls those controls may not get compiled in the right order. Also you need to always make sure that all dependencies are available when compiling which means making sure all libraries and business logic and even Process code is available - otherwise the PRG compiler will complain about missing functions etc.

I tend to run in nPageParseMode=2 which checks for changes and tries to recompile at runtime. There are problems with that too (unloads and perhaps some instance not seeing the recompile) but overall I think that's more reliable in the long run.

+++ Rick ---

© 1996-2024