Here's my solution to the "can't combine constant arrays"... record constants with booleans in them. I'm posting code because of the truly ugly "decide based on four booleans" decision tree that I had to code. I decided that "A XOR B NAND C XNOR D" type code was just not maintainable so I went with one if statement per use case. I decided to include a picture of the code because that's what I see and I think it's easier to read.
Here's my solution to the "can't combine constant arrays"... record constants with booleans in them. I'm posting code because of the truly ugly "decide based on four booleans" decision tree that I had to code. I decided that "A XOR B NAND C XNOR D" type code was just not maintainable so I went with one if statement per use case. I decided to include a picture of the code because that's what I see and I think it's easier to read.
type
TInstallRec = record
ProgramOne: Boolean;
ProgramTwo: Boolean;
Name: string;
end;
const
INSTALL_FILES: array[1..82] of TInstallRec = (
{ 1}(ProgramOne: True; ProgramTwo: True; Name: 'data.zip'),
function FileInInstallList(const Filename: string; IncludeSolutionlink, IncludeVisionlink: Boolean): Boolean;
var
i: Integer;
begin
result := False;
i := Low(INSTALL_FILES);
while (not result) and (i <= High(INSTALL_FILES)) do
begin
result := SameText(Filename, INSTALL_FILES[i].Name);
// four cases from parameters considered separately to make it easier to understand
if aIncludeProgramOne and aIncludeProgramTwo then // 1: both true, we want all matching files
result := result
else if aIncludeProgramOne and not aIncludeProgramTwo then // 2: ProgramOne (and common files)
result := result and INSTALL_FILES[i].ProgramOne
else if not aIncludeProgramOne and aIncludeProgramTwo then // 3: ProgramTwo (and common files)
result := result and INSTALL_FILES[i].ProgramTwo
else if not aIncludeProgramOne and not aIncludeProgramTwo then // 4: neither, just the 'special' extra files
result := result and not INSTALL_FILES[i].ProgramOne and not INSTALL_FILES[i].ProgramTwo;
Inc(i);
end; // while
end;
I've used CnPack in the past, I don't think I have it installed now though.
ReplyDeleteCNPack gives me the colouring, but I also have GExperts. I'm pretty sure CNPack does that as soon as you install it.
ReplyDeleteYea GExperts is nice too, especially the project wide regexp search, which also searches dfm files. Been a real time saver that one.
ReplyDelete