* TUTOLAN.PRG
* C:\PROGRAM FILES (X86)\ABAQUE\FICSAMPLES\FICTUTO\TUTOLAN.PRG (included in c:\program files (x86)\abaque\ficsamples\fictuto\fictutobs.exe)
* (71 lines before localization)
* ========================================================================================================================

&& Main program for desktop (LAN) version

lparameters cForm as String, parm1, parm2
cForm = Evl(m.cForm, 'index')

local loDefault as abSet of abDev.prg;
, tutoSets as tutoSets of tutoSets.prg;
, AppResult as String;
, oForm as Form;
, cParms as String;

* Clean up workspace (mostly for dev)
close tables all
for each oForm in _screen.Forms foxobject
  oForm.release
endfor

* Load public FoxInCloud resources
do (Home(1) + 'tools\ab\ab.prg')

* Set project's root folder as default
loDefault = abSet('default', Addbs(JustPath(Sys(16)))) && abSet(): modify command abDev.prg - SET and reSET when program ends

&& Once you've moved all your app's initialization code into your shared 'xxxSets' environment class (here 'tutoSets'),
&& all you need to do here is instantiate the class after making sure the procedure where it lives is in
&& Set('procedure')
&& When this program ends, VFP destroys the variable and the tutoSets object it holds a reference to, and tutoSets.Destroy() restores environment.

set procedure to progs\tutoSets additive && better use set procedure to + createObject() rather then newObject()
tutoSets = CreateObject('tutoSets', @m.AppResult) && Environment class shared with Web application

* abCoverage = abCoverage() && uncomment to start coverage

cParms = Pcount()
cParms = ICase(;
  m.cParms <=1,;
    '',;
  m.cParms <=2,;
    'm.parm1',;
  m.cParms <=3,;
    'm.parm1, m.parm2',;
    '';
  )

do case
case !Vartype(m.tutoSets) == 'O'
  MessageBox(ICase(;
    cLangUser() = 'fr',  [Désolé, l'application n'a pas démarré :],; && copy-paste this line to add another language support
                        [Sorry, Application did not start:]; && Default: English
  ) + ' ' + m.AppResult, 16, 'FoxInCloud Live Tutorial')

* Open startup form
case File(ForceExt(m.cForm, 'scx'))
  cParms = nEvl(m.cParms, 'with ' + m.cParms)
  do form (m.cForm) &cParms
  read events
otherwise
  cParms = nEvl(m.cParms, ', ' + m.cParms)
  oForm = CreateObject(m.cForm &cParms)
  oForm.Show(1)
endcase

&& You don't need anything else as xxxSets.Destroy() (here 'tutoSets.Destroy()') executes all required clean up code.