pascalscript - Uncheck a task checkbox at setup initialisation -
in inno setup script there's task may used under conditions determined code. in no other conditions task should executed. in fact entire tasks page skipped then. unfortunately task selection remembered inno setup , restored on every following update setup, if page isn't visible @ all.
i need uncheck task @ every setup initialisation in order forget last selected state. can't work. here's latest try:
[tasks] name: deleteconfig; description: "{cm:task_deleteconfig}"; flags: unchecked #define task_deleteconfig_index 0 [installdelete] ; delete user configuration files if task selected type: files; name: "{userappdata}\...\app.conf"; tasks: deleteconfig [code] var isdowngradesetup: boolean; function initializesetup: boolean; begin // more code not shown here, following may set under conditions isdowngradesetup := true; end; procedure initializewizard; begin // clear possibly remembered value previous downgrade install wizardform.taskslist.checked[{#task_deleteconfig_index}] := false; end; function shouldskippage(pageid: integer): boolean; begin // make upgrade install quicker result := ((pageid = wpselecttasks) or ((pageid = wpready) , (getarraylength(products) = 0))) , previnstallexists; end; procedure curpagechanged(curpageid: integer); begin if curpageid = wpwelcome begin if previnstallexists begin // change "next" button "upgrade" on first page, because won't ask more wizardform.nextbutton.caption := expandconstant('{cm:upgrade}'); wizardform.finishedheadinglabel.caption := expandconstant('{cm:updatedheadinglabel}'); end; end; if curpageid = wpselecttasks begin if isdowngradesetup begin // pre-select task delete existing configuration on downgrading (user can deselect again) // (use zero-based index of rows in tasks list gui) // source: http://stackoverflow.com/a/10490352/143684 wizardform.taskslist.checked[{#task_deleteconfig_index}] := true; end; end; end;
this gives me a
runtime error (at 85:77): list index out of bounds (0).
i don't know "85:77" supposed recent changes can quoted code above.
i first had in initializesetup
function didn't work either.
where should put code works , finds initialised tasks list? tasks page may not shown think it's late wait page become visible. in fact code used there , wasn't called when page skipped.
i not understand, why need reset task. have impression have conditional skip of task implemented incorrectly.
it's guess, assume skip task page using shouldskippage
. task stays checked, if enabled in previous installation.
do not use shouldskippage
this, use check
parameter instead. if there's single task conditionally disabled using check
parameter, whole task page gets skipped.
[tasks] name: deleteconfig; description: "{cm:task_deleteconfig}"; flags: unchecked; \ check: usedeleteconfig [code] function usedeleteconfig: boolean; begin result := isdowngradesetup; end;
to answer actual question, can this:
procedure curpagechanged(curpageid: integer); begin if curpageid = wpready begin if previnstallexists begin wizardform.taskslist.checked[0] := false; end; end; end; function updatereadymemo( space, newline, memouserinfoinfo, memodirinfo, memotypeinfo, memocomponentsinfo, memogroupinfo, memotasksinfo: string): string; begin if previnstallexists begin memotasksinfo := ''; end; end;
though again, not think, solution.
or easier, use useprevioustasks
:
[setup] useprevioustasks=no
or using checkedonce
flag:
[tasks] name: deleteconfig; description: "{cm:task_deleteconfig}"; flags: unchecked checkedonce
Comments
Post a Comment