Subversion Repositories factorylink.valmet

Rev

Blame | Last modification | View Log | Download

; -- im_bas.iss --
; Copyright (C) 2002 RLD Automation
; FL7.0, Windows 2000

[Setup]
DisableStartupPrompt=yes
DisableProgramGroupPage=yes
DisableReadyMemo=yes
DisableReadyPage=yes
DisableFinishedPage=yes
DisableDirPage=yes
DiskSpanning=0
AppName=FactoryLink Task
AppVerName=FactoryLink Task Version 0.1, for FL7.0 NT4 (with SP4 or higher) or Windows 2000
AppCopyright=Copyright © 2002 RLD Automation.
DefaultDirName={code:GetPrgDir|{pf}\im_bas}
;DefaultGroupName=Wizard Information Systems
DirExistsWarning=no
MinVersion=4,4
OutputBaseFileName=RLDTitle
OutputDir=..\..\Flink\xbin
;WizardImageFile=..\ModernImage.bmp
;WizardSmallImageFile=..\SmallImage.bmp
UsePreviousAppDir=no
Uninstallable=no
;UninstallDisplayIcon={app}\im_bas.exe
;UninstallDisplayName=FactoryLink IM-BAS Driver
;UninstallFilesDir={app}\bin\im_bas
AppPublisher=Wizard Information Systems
AppVersion=0.1
AppPublisherURL=http://www.wizinfosys.nl/
AppSupportURL=support@wizinfosys.nl
AppUpdatesURL=http://www.wizinfosys.nl/
;LicenseFile=..\license.txt
WizardStyle=modern
UninstallStyle=modern
WindowVisible=no
BackColor=clSilver
BackColor2=clBlack
BackColorDirection=toptobottom
;WizardDebug=no

[Files]

[Registry]

[Run]

[UninstallRun]

[InstallDelete]

[Messages]

[Code]
var
  DriverList: String;

{Read the FactoryLink directory from the autostart service program location,
 using the environment variable FLINK will result in a directory with
 short names. By using the autostart server the long names are found, and
 the setup progam will use these names instead of the notation in short}
function GetPrgDir(S: String): String;
var
  MyDir: String;
begin

  {read the autostart service directory, filename and extension}
  RegQueryStringValue( HKEY_LOCAL_MACHINE, 'System\CurrentControlSet\Services\FactoryLink Autostart Service', 'ImagePath', MyDir);
  
  {remove the filename and last '\' character}
  MyDir := ExtractFileDir( MyDir);
  
  {now the bin subdir is removed.....}
  MyDir := ExtractFileDir( MyDir);

  {return default in case no directory is found}
  if (Length( MyDir) <= 0) then begin
    MyDir := S;
  end;
  
  {return the directory to install the program}
  Result := MyDir;
end;

{Get the driver string for modifying the tree view of the
 Configuration Explorer}
function GetDriverString(DefaultInput: String): String;
begin
  { Return the driver list }
  Result := DriverList;
end;

{Add a AC line for the current task to the titles file, add a line
 to the CTlist file. The taskname and ct-line are specified in the
 function-parameter: taskname,ct-line}
function AddTitle( MyEntry: String): Boolean;
var
  MyText: TArrayOfString;
  MyFile: String;
  MyAC: String;
  MyCT: String;
  k: Integer;
  found: Integer;
begin

  {first file to load is th etitles file in the AC directory}
  MyFile := GetPrgDir( '') + '\ac\titles';
  k := LoadStringsFromFile( MyFile, MyText);
  
  {AC entry looks like: taskname.ac}
  k := Pos( ',', MyEntry);
  if k = 0 then k := Pos( ':', MyEntry);
  MyAC := Copy( MyEntry, 0, k-1) + '.ac';
  MyCT := MyEntry;
  StrSet( ':', k, MyCt);
  
  {search for ac entry}
  found := 0;
  k := 0;
  while (k < GetArrayLength(MyText)) and (not found) do begin

    found := Pos( MyAC, MyText[ k]);
    k := k + 1;
  end;
  
  {if the entry is not found, add a line to the titles file}
  if (found = 0) then begin

    SetArrayLength(MyText, GetArrayLength(MyText)+1);
    MyText[ GetArrayLength(MyText)-1] := MyAC;
    SaveStringsToFile( MyFile, MyText, false);
  end;

  {add entry to ctlist file}
  MyFile := GetPrgDir( '') + '\ctgen\ctlist';
  k := LoadStringsFromFile( MyFile, MyText);

  {search for ctgen entry}
  found := 0;
  k := 0;
  while (k < GetArrayLength(MyText)) and (not found) do begin

    found := Pos( MyCT, MyText[ k]);
    k := k + 1;
  end;

  {if the entry is not found, add a line to the ctlist file}
  if (found = 0) then begin

    SetArrayLength(MyText, GetArrayLength(MyText)+1);
    MyText[ GetArrayLength(MyText)-1] := MyCT;
    SaveStringsToFile( MyFile, MyText, false);
  end;

  {return always true, ac file must be installed, this function
   only adds a line to the titles file}
  Result := True;
end;

{Remove a AC line for the current task in the titles file, and remove
 a line in the CTlist file the entry is specified with the task name
 in the function-parameter}
function RemoveTitle( MyEntry: String): Boolean;
var
  MyText: TArrayOfString;
  MyFile: String;
  MyAC: String;
  MyCT: String;
  Temp: String;
  k: Integer;
  found: Integer;
begin

  MyAC := MyEntry + '.ac';
  MyCT := MyEntry + ':';
  
  {search the task name in the ctlist file}
  MyFile := GetPrgDir( '') + '\ctgen\ctlist';
  msgbox( MyFile, 0, 0);
  SetArrayLength( MyText, 0);
  k := LoadStringsFromFile( MyFile, MyText);

  {search for the task name}
  for k:=0 to GetArrayLength(MyText)-1 do begin

    Temp := MyText[ k];
    if (found = 0) then
      found := Pos( MyCT, MyText[ k]);

    {if the entry is found, remove the line from the titles file}
    if (found) then begin

      if ((k+1) < GetArrayLength(MyText)) then begin

        MyText[ k] := MyText[ k+1];
      end else {begin;}
        MyText[ k] := '';
    end;
  end;

  if (found) then begin

    {shorten array with one}
    SetArrayLength( MyText, GetArrayLength( MyText) - 1);
    SaveStringsToFile( MyFile, MyText, false);
  end;
  
  {search the task name in the titles file}
  MyFile := GetPrgDir( '') + '\ac\titles';
  k := LoadStringsFromFile( MyFile, MyText);
  found := 0;

  {search for the task name}
  for k:=0 to GetArrayLength(MyText)-1 do begin

    Temp := MyText[ k];
    if (found = 0) then
      found := Pos( MyAC, MyText[ k]);

    {if the entry is found, remove the line from the titles file}
    if (found) then begin

      if ((k+1) < GetArrayLength(MyText)) then begin

        MyText[ k] := MyText[ k+1];
      end else {begin;}
        MyText[ k] := '';
    end;
  end;

  if (found) then begin

    {shorten array with one}
    SetArrayLength( MyText, GetArrayLength( MyText) - 1);
    SaveStringsToFile( MyFile, MyText, false);
  end;

  {return always true, ac file must be removed}
  Result := True;
end;

function InitializeSetup(): Boolean;
var
  TaskName: String;
  k: Integer;
begin

  TaskName := GetCmdTail();

  for k:=0 to ParamCount() do begin

    TaskName := Uppercase( ParamStr( k));

    if (Pos( '/DEBUGWND=', TaskName)) then
      RemoveTitle( Lowercase(Copy( TaskName, 11, Length( TaskName) - 10)));

    if (Pos( '/ADD=', TaskName)) then
      AddTitle( Lowercase(Copy( TaskName, 6, Length( TaskName) - 5)));

    if (Pos( '/REMOVE=', TaskName)) then
      RemoveTitle( Lowercase(Copy( TaskName, 9, Length( TaskName) - 8)));
  end;

  {always quit here.....}
  Result := False;
end;