NetTalk Central

NetTalk Web Server => Web Server - Ask For Help => Topic started by: HPabon on January 12, 2015, 10:29:17 AM

Title: Change template port number
Post by: HPabon on January 12, 2015, 10:29:17 AM
Hi,

Is there a way to change on the fly, the port number assigned in the NT template?

I want to read the listening port from a file instead of assigning it in the template.

TIA

Hector
Title: Re: Change template port number
Post by: Poul Jensen on January 12, 2015, 01:45:39 PM
Hi Hector,

To read the portnumber from an inifile:

In WebServer Procedure

    ! Start of "NetTalk Object Before Init Section"
    PortNum# = getini('KundeProg', 'Port', '88', clip(path()) & '\KundeProg.ini' )
    do CheckOmittedWeb
    If Net:ShortInit
        s_web &= pServer
    Else
        s_web &= ThisWebServer
        s_web.SuppressErrorMsg = 1         ! No Object Generated Error Messages ! Generated by NetTalk Extension
        s_web.init()
        s_web.Port = PortNum#
        0{prop:text} = clip(0{prop:text}) & ' | Port:' & s_web.Port & ' |Inifil: ' & clip(GLO:Inifil) & ' | '
        s_web.Open()
        Get(s_web._SitesQueue,1)
    End
       
    OMIT('***HERTIL***')   


And

   ! Start of "NetTalk Object After s_web assigned"
     ***HERTIL***

Cheers,
/Poul
Title: Re: Change template port number
Post by: Bruce on January 12, 2015, 08:33:55 PM
Poul is close, but misses a trick.

The setting in the template is an expression, so instead of 88 or 80 you can just use a variable. Say
loc:port

Then in the embed code you just load loc:port from an ini file or xml file or whatever. Usually I put the field on a "settnigs" tab as well.

See the MultiSite Host app for an example of this.

Cheers
Bruce