PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → WB19 - Project Init Code
WB19 - Project Init Code
Iniciado por guest, 15,feb. 2015 14:19 - 5 respuestas
Publicado el 15,febrero 2015 - 14:19
Hi everyone -

I have a 1 or 2 dozen projects that use the same Project init code. It's a pain to update them all as things change. Is it possible to reference a file or something in the init code so I can change just that one file? Or perhaps I could put the code somewhere and then share it among projects?

Thanks - J

Here's the code fyi:

Nation(nationAmerican)

//Set Global Variables
gpsSQL is string

//Set Global Class Names
gpoDB is clDBase
gpoEmail is clEmail
gpoError is clError
gpoPrj is clProject
//gpoAttn is clAttendance
//gpoLogin is clLogin
//gpoMemberships is clMemberships
//gpoRanks is clRanks

//Set Data Sources Variable Names
gpsdAttendanceRecords is Data Source
gpsdClasses is Data Source
gpsdClassEnrollments is Data Source
gpsdComm is Data Source
gpsdCommRecip is Data Source
gpsdContacts is Data Source
gpsdEvents is Data Source
gpsdEventRegistrations is Data Source
gpsdInvoices is Data Source
gpsdInvoiceLineItem is Data Source
gpsdLibrary is Data Source
gpsdLibrarytemplates is Data Source
gpsdListItems is Data Source
gpsdLogin is Data Source
gpsdLoginLogs is Data Source
gpsdLogs is Data Source
gpsdPrograms is Data Source
gpsdProgramEnrollments is Data Source
gpsdRanks is Data Source
gpsdRankLogs is Data Source
gpsdReportDataSource is Data Source
gpsdSelectedList is Data Source
gpsdStudioInfo is Data Source
gpsdTests is Data Source
gpsdTestResults is Data Source
gpsdTestRegistrations is Data Source
gpsdWebsite is Data Source
gpsdWebsiteMenuItems is Data Source
gpsdWebsitePages is Data Source
gpsdWebsiteTemplates is Data Source

//Set MAFA Data Source Variable Names
gpsdMAFALibrary is Data Source

//Initialize Database and Connection to server
gpoDB:InitDbase()
gpoPrj:GetURLParameters() //has to run after InitDbase
gpoDB:MAFA_Dbase_Open_Master()

//Open Data Sources
gpoDB:Init_HFAttendance()
gpoDB:Init_HFClasses()
gpoDB:Init_HFClientClasses()
gpoDB:Init_HFClientPrograms()
gpoDB:Init_HFComm()
gpoDB:Init_HFCommRecip()
gpoDB:Init_HFContact()
gpoDB:Init_HFEvents()
gpoDB:Init_HFEventRegistrations()
gpoDB:Init_HFInvoices()
gpoDB:Init_HFInvoiceLineItem()
gpoDB:Init_HFLibrary()
gpoDB:Init_HFLibraryTemplates()
gpoDB:Init_HFListItems()
gpoDB:Init_HFLoginLogs()
gpoDB:Init_HFLogs()
gpoDB:Init_HFPrograms()
gpoDB:Init_HFRanks()
gpoDB:Init_HFRankLogs()
gpoDB:Init_HFSelectedList()
gpoDB:Init_HFStudioInfo()
gpoDB:Init_HFTests()
gpoDB:Init_HFTestResults()
gpoDB:Init_HFTestRegistrations()
gpoDB:Init_HFWebsite()
gpoDB:Init_HFWebsitePages()
gpoDB:Init_HFWebsiteMenuItems()
gpoDB:Init_HFWebsiteTemplates()

//Set Initial Message
gpoPrj:m_sNotify = "Welcome to the MAFA Studio Manager"

//Run Various setup processes
gpoPrj:Studio_GetInfo()
gpoPrj:Session_GetSessionID()
gpoPrj:Session_GetInfo()
IF InTestMode() = False THEN
gpoPrj:Session_TestIfExpired()
END

//START PROJECT SPECIFIC CODE:
Publicado el 15,febrero 2015 - 16:39
Hi Joel

"extern" is a keyword that can be used for two completely different things

1. you can use it to tell the compiler that a variable is declared somewhere else, and that it will know about it at execution time (you don't care here)

2. you can use it to include an EXTERNAL source (text) in the regular one... So if you take your source and put it in a text file, then in each project you refer to it with an extern "c:\....\myProjectSource.wl", you should get what you requested... It is most often used to include lists of constants (for api use), but I don't see why it wouldn't work in your case

Best regards
Publicado el 17,febrero 2015 - 15:34
Thank you Fabrice - I'll give it a try!
Publicado el 18,febrero 2015 - 15:12
Hi again Fabrice -

I haven't tried it yet, but I have a question. Is there a place I can put this text file - in a project, so that when I upload the project to the server, it'll always be there? And then, how would I refer to the text file from other projects, without going through the whole "C:\Dir\Dir\ extFile" thing? Is there such a thing as a common directory to all projects?
Publicado el 18,febrero 2015 - 18:37
Hi Joel

you are confusing your source code with the publish version... We were talking about an extern of SOURCE code... It doesn't change a thing on the published side, where your source has been transformed (including the extern part) in to pages and wdl.

Best regards
Publicado el 18,febrero 2015 - 18:40
Ah - ok.

So when it publishes, it pulls in the extern parts and brings it all together. Got it!

thank you - that is very helpful!