/* Installationsdatei fr EuraPM2 */
/* Demo-Version  */
/* Paketversion 0.24 */

call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs' 
call SysLoadFuncs
call RxFuncAdd 'ErxLoadFuncs', 'EClient', 'ErxLoadFuncs' 
call ErxLoadFuncs

parse arg Run hwnd Lkz New

say 'Install Version 0.24' Run

/* Listbox fllen */
if Run=='Start' then
do 
   call IrxSetTitle hwnd, "EuraPM2 - Installation - Paket 0.24"
/*   say 'LKZ = 'lkz New    */
   if Lkz==49 then
   do 
      call IrxAddTable hwnd, "Vorwahlen",  0, 'm'
      call IrxAddTable hwnd, "Rufnummern", 1, 'm'
      if New==1 then
         call IrxAddTable hwnd, "Provider",  13, 'm'
      else
         call IrxAddTable hwnd, "Provider",  13, 'n'
      call IrxAddTable hwnd, "Tarife",    15, 'm'
      if New==1 then
         call IrxAddTable hwnd, "Zonen",     16, 'm'
      else
         call IrxAddTable hwnd, "Zonen",     16, 'n'
      call IrxAddTable hwnd, "Feiertage",  17, 'm'
   end /* do */
   else
   do 
      /* OK, ist ja eigentlich doppelt */
      call IrxAddTable hwnd, "Vorwahlen",  0, 'm'
      call IrxAddTable hwnd, "Rufnummern", 1, 'm'
      call IrxAddTable hwnd, "Provider",  13, 'n'
      call IrxAddTable hwnd, "Tarife",    15, 'n'
      call IrxAddTable hwnd, "Zonen",     16, 'n'
      call IrxAddTable hwnd, "Feiertage",  17, 'n'
   end /* do */
   exit 0
end /* do */

/* Installation starten */
if Run=='Install' then
do 
   parse arg Run this Backup Lkz WPS
   if Backup==1 then 
   do 
      rc = IrxBackUp( this )
      if rc>0 then exit rc    /* Backup fehlgeschlagen */
   end /* do */
    
   rc = CopyFile( this, "file_id.diz" )
   rc = CopyFile( this, "Doku.INF" );
   rc = CopyFile( this, "De_Inst.cmd" );
   rc = CopyFile( this, "Install.cmi" );
   rc = CopyFile( this, "quit.cmd" );
   rc = CopyFile( this, "Konfig.exe" );
   rc = CopyFile( this, "Konfig.hlp" );
   rc = CopyFile( this, "Install.exe" );
   rc = CopyFile( this, "Gebhr.exe" );
   rc = CopyFile( this, "TBuch.exe" );
   rc = CopyFile( this, "Monitor.exe" );
   rc = CopyFile( this, "EServer.cfg", , 'q' );
   rc = CopyFile( this, "LCR.exe" );
   rc = CopyFile( this, "Easy.lcr", ,'n' );
   rc = CopyFile( this, "Full.lcr", ,'n' );
   rc = CopyFile( this, "EServer.exe" );
   rc = CopyFile( this, "CaLib.Dll" );
   rc = CopyFile( this, "EClient.dll" );
   rc = CopyFile( this, "CaTable.dll" );
   rc = CopyFile( this, "CaTable.exe" );
   rc = CopyFile( this, "toolbox.ico" );
   rc = CopyFile( this, "toolbox1.ico" );
   rc = CopyFile( this, "QueryDB.cmd", ,'n' );
   rc = CopyFile( this, "PrintTax.cmd", , 'n' );
   rc = CopyFile( this, "Vorwahl.dat" );

   if Lkz==49 then 
   do 
      rc = CopyTable( this, 0, "Vorw49", "Vorwahlen", "Vorwahl" )
      rc = CopyTable( this, 1, "RufN49", "Rufnummern", "RufNum" )
      rc = CopyTable( this, 13, "Provider" );
      rc = CopyTable( this, 15, "Tarife" );
      rc = CopyTable( this, 16, "Zonen" )
      rc = CopyTable( this, 17, "Feiertag", "Feiertage", "Feiertag" )
   end /* do */
   else
   do 
      rc = CopyTable( this, 0, "VorwXX", "Vorwahlen", "Vorwahl" )
      rc = CopyTable( this, 1, "RufNXX", "Rufnummern", "RufNum" )
      /* Provider, Tarife, Zonen und Feiertage fr Ausland sind nicht vorhanden */
   end /* do */
   exit 0
end /* do */

if Run=='WPS' then
do 
   parse arg Run this Path
   say 'erzeuge Ordner'
   rc = SysCreateObject( 'WPFolder', "EuraPM2", "<WP_DESKTOP>", "OBJECTID=<WP_EURAPM2FOLDER>;ICONFILE="Path"\toolbox1.ico;ICONNFILE=1,"Path"\toolbox.ico;ALWAYSSORT=YES;", "update" );
   if rc==0 then
   do 
      say 'Ordner konnte nicht erzeugt werden'
      exit 1000;
   end /* do */
   else 
   do 
      call MakeProgram Path, "Konfig",         "WP_EURAPM2KONFIG",  "Konfig.exe"
      call MakeProgram Path, "Gebhr",         "WP_EURAPM2TAXES",   "Gebhr.exe"
      call MakeProgram Path, "Quit Server",    "WP_EURAPM2QUIT",    "QUIT.cmd"
      call MakeProgram Path, "Monitor",        "WP_EURAPM2MONITOR", "Monitor.exe"
      call MakeProgram Path, "Telefonbuch",    "WP_EURAPM2TBUCH",   "TBuch.exe"
      call MakeProgram Path, "LCR",            "WP_EURAPM2LCR",     "LCR.exe"
      call MakeProgram Path, "Setup",          "WP_EURAPM2SETUP",   "Install.exe"
      call MakeShadow  Path, "WP_EURAPM2CFG",  "EServer.cfg"
      call MakeShadow  Path, "WP_EURAPM2PRINTTAX",  "PrintTax.cmd"
      rc = SysCreateObject( "WPProgram", 'Doku', "<WP_EURAPM2FOLDER>", "OBJECTID=<WP_EURAPM2DOKU>;EXENAME=VIEW.EXE;PARAMETERS="Path"\Doku.INF", 'update' );
      if rc==0 then
         say 'Objekt Doku konnte nicht erzeugt werden'

   end /* do */
end /* do */

exit 0

MakeProgram:
procedure 
parse arg Path, Title, id, exe
Path = translate( Path )
exe = translate( exe )
Param = "OBJECTID=<"id">;EXENAME="Path"\"exe";STARTUPDIR="Path
say 'erzeuge Programmobjekt' Title /* Param */
rc = SysCreateObject( "WPProgram", Title, "<WP_EURAPM2FOLDER>", Param, 'U' );
if rc==0 then
   say 'Objekt 'Title' konnte nicht erzeugt werden'
return 0

MakeShadow:
procedure 
parse arg Path, id, File
Param = "OBJECTID=<"id">;SHADOWID="Path"\"File
say 'erzeuge Referenz' File /* Param */
rc = SysCreateObject( "WPShadow", '.', "<WP_EURAPM2FOLDER>", Param, 'U' );
if rc==0 then
   say 'Objekt 'Title' konnte nicht erzeugt werden'
return 0

CopyFile:
procedure 
parse arg this, Src, Dest, Opt
rc = IrxCopyFile( this, Src, Dest, Opt )
if rc>0 then 
do 
   say 'IrxCopyFile = 'rc 
   if rc!=27 then
      say ErxGetErrorText( rc )
   exit rc
end /* do */
return 0

CopyTable:
procedure
parse arg this, Typ, Src, Dest, Alt
rc = IrxCopyTable( this, Typ, Src, Dest, Alt )
if rc>0 then 
do 
   say 'IrxCopyTable = 'rc
   if rc!=27 then
      say ErxGetErrorText( rc )
   exit rc
end /* do */
return 0


