Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

showing a summary of selected features


2 replies to this topic

alexv

alexv
  • Members
  • 2 posts

Posted 11 October 2006 - 11:54

Hello.
I'm using InstallShield 12 and I'm working on a InstallScript project which has many features and subfeatures. It's a big list (imagine a list of many fonts which are to be selected by the end-user - just an example). After the SdFeatureTree dialog and before the copy process starts I want to display a summary of selected features. Now, I know it's possible to check if a feature is selected or not (using the FeatureIsItemSelected function) but having many features put's me in difficulty using that function. Isn't there a dynamic way to make a list of selected features and sub-features that I can display using SdShowInfoList?
Please help me on this one, I've searched the forum and did not find relevant information regarding my problem. I also googled and still no answer.

Edited by alexv, 11 October 2006 - 11:56.


Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 11 October 2006 - 15:40

FeatureListItems() generates a list of all sub features for a given feature. You can use this to build a list of all features at runtime.

alexv

alexv
  • Members
  • 2 posts

Posted 12 October 2006 - 13:38

Thank you for your answer.
FeatureListItems returns only the main tree of features (not including the subfeatures).
I had to build a recursive function that would add all selected features to a list (main tree and sub-trees).
I want to share the code for anyone else will encounter this problem.
This works for as many sub-features as you like. It will add all the selected features to a list.
here it is:
I call this function immediately after the feature tree dialog SdFeatureTree.
Let's say you have a string list called listData that will be displayed before the SdSetupCopy dialog. This list will hold the selected features after calling the function.

CODE
GetSelectedFeatures("",listData,"     ");
//To display the list you could call:
//SdShowInfoList("Install setup" , "You selected these features:" , listData);


First arguments is meant to be an empty string - the full tree of features.
Second argument is the list where to add the selected features.
Third argument is the space to be added before the strings that are inserted in listData.

CODE
export prototype GetSelectedFeatures(STRING, BYREF LIST, STRING);

//--------------------------------------------------------------------------    
//Get the list of all selected features and subfeatures
//--------------------------------------------------------------------------

function GetSelectedFeatures(sFeatureTree, lData, sSpacer)
LIST listFeatures;
STRING sFeature, sFeatureEx;
NUMBER nFeature;
begin
   listFeatures = ListCreate(STRINGLIST);
   FeatureListItems(MEDIA,sFeatureTree,listFeatures);
   nFeature=ListGetFirstString(listFeatures,sFeature);
   while (nFeature!=END_OF_LIST)
 if (FeatureIsItemSelected(MEDIA,sFeature)) then
  sFeatureEx=sFeature;
  StrReplace(sFeatureEx,sFeatureTree+"\\","",0);
  ListAddString(lData,sSpacer+sFeatureEx,AFTER);
  sFeatureEx=NOTHING;
  GetSelectedFeatures(sFeature,lData,sSpacer+sSpacer);
 endif;
    nFeature=ListGetNextString(listFeatures,sFeature);
   endwhile;
   ListDestroy(listFeatures);
   return 0;
end;


I hope it will be of use.
Alex.