dateversioninno-setupcomputed-values

How do you add installation related computed strings to InnoSetup scripts?


Currently when I upgrade a program I backup the existing files to a folder named backup in the program directory eg .

Source: "{app}\filename.exe"; DestDir: "{app}\backup"; Flags: external skipifsourcedoesntexist uninsneveruninstall

Is there a way to specify or compute a strings so the code is something like

Source: "{app}\filename.exe"; DestDir: "{app}\backup{date}"; Flags: external skipifsourcedoesntexist uninsneveruninstall

or combine a date with info on the previous version

Source: "{app}\filename.exe"; DestDir: "{app}\backup{previous version}{date}"; Flags: external skipifsourcedoesntexist uninsneveruninstall

Solution

  • Please read Pascal Scripting: Scripted Constants and Pascal Scripting: Support Functions Reference. Also read this and this. Anyway, this is how I did it:

    [Dirs]
    ; create an empty folder...
    Name: "{app}\{code:MyDateTimeString}"
    
    [Code]
    function MyDateTimeString(Param: String): String;
    begin
      Result := GetDateTimeString('yyyy.mm.dd_hh.nn.ss', #0, #0);
    end;