Need a beta tester or two....

If you created a new screenset and want to share it with others then please post it here. You can talk about screens here.

Re: Need a beta tester or two....

Postby cncdrive » Sat Jan 07, 2017 1:12 am

I have one idea, a workaround is to check if majorversion = 1.0 or 1.1 and then do not install and show error otherwise install.
This will work, because there is currently only majorversion 1.0 and 1.1 and 1.2 and it will still work if version will become 1.3 or later.
So, I figured this workaround for you. :)
cncdrive
Site Admin
 
Posts: 4719
Joined: Tue Aug 12, 2014 11:17 pm

Re: Need a beta tester or two....

Postby ger21 » Sat Jan 07, 2017 2:17 am

OK, I changed it to do that, and this code works. (I changed the registry value to test it)
So if anyone wants to do something similar, you can just add this section to Inno Setup.

Thanks for the help. :)

Code: Select all
[Code]

function InitializeSetup(): Boolean;

var
MVCheck: string;

begin
Result := False;
RegQueryStringValue(HKEY_CURRENT_USER, 'Software\CNCdrive\UCCNC', 'MajorVersion', MVCheck)


if (MVCheck = '1.0') then begin
MsgBox('The 2017 Screenset requires UCCNC Version 1.2xx or later - Installation aborting.', mbError, MB_OK);
end

else if (MVCheck = '1.1') then begin
MsgBox('The 2017 Screenset requires UCCNC Version 1.2xx or later - Installation aborting.', mbError, MB_OK);
end

else begin
Result := True;
end

end;
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2671
Joined: Sat Sep 03, 2016 2:17 am

Re: Need a beta tester or two....

Postby SiSt » Sat Jan 07, 2017 7:45 am

That solution is pretty okay for this scenario. In case anyone needs an more generic one, this would be my approach:

Code: Select all
[Code]

function CompareVersion(V1, V2: string): Integer;
var
  P, N1, N2: Integer;
begin
  Result := 0;
  while (Result = 0) and ((V1 <> '') or (V2 <> '')) do
  begin
    P := Pos('.', V1);
    if P > 0 then
    begin
      N1 := StrToInt(Copy(V1, 1, P - 1));
      Delete(V1, 1, P);
    end
      else
    if V1 <> '' then
    begin
      N1 := StrToInt(V1);
      V1 := '';
    end
      else
    begin
      N1 := 0;
    end;

    P := Pos('.', V2);
    if P > 0 then
    begin
      N2 := StrToInt(Copy(V2, 1, P - 1));
      Delete(V2, 1, P);
    end
      else
    if V2 <> '' then
    begin
      N2 := StrToInt(V2);
      V2 := '';
    end
      else
    begin
      N2 := 0;
    end;

    if N1 < N2 then Result := -1
      else
    if N1 > N2 then Result := 1;
  end;
end;

function InitializeSetup(): Boolean;
var
  MVCheck : string;
  RequiredVersion : string;
begin
  RequiredVersion := '1.2'
  RegQueryStringValue(HKEY_CURRENT_USER, 'Software\CNCdrive\UCCNC', 'MajorVersion', MVCheck);

  if CompareVersion(MVCheck, RequiredVersion) < 0 then begin
    if (MsgBox('Your version of UCCNC ' + MVCheck + ' is too old. This screen will not work prior version 1.2. Do you want to install it nonetheless?',
        mbConfirmation, MB_YESNO) = IDNO) then
     begin
        Result := False;
        Exit;
    end;
  end;
end;
SiSt
 
Posts: 4
Joined: Thu Dec 29, 2016 8:57 pm

Re: Need a beta tester or two....

Postby ger21 » Sat Jan 07, 2017 12:46 pm

I think I found the answer. First hit when Googling "Pascal Compare Version".

Rather than trying to compare two reals or doubles, split the version # into two integers, which are much easier to work with, and compare the integers.
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2671
Joined: Sat Sep 03, 2016 2:17 am

Previous

Return to Custom Screensets

Who is online

Users browsing this forum: No registered users and 4 guests