else if (compsDone == gControls->cfg->st[instChoice].numComps)
else if (compsDone >= gControls->cfg->st[instChoice].numComps)
GenerateIDIFromOpt(Str255 idiName, long dirID, short vRefNum, FSSpec *idiSpec){	Boolean bSuccess = true;	OSErr 	err;	short	refNum, instChoice;	long 	count, compsDone, i, j;	char 	*buf, *fnum, *keybuf, ch;	Str255	pfnum, pkeybuf;	err = FSMakeFSSpec(vRefNum, dirID, idiName, idiSpec);	if ((err != noErr) && (err != fnfErr))	{		ErrorHandler();		return false;	}	err = FSpCreate(idiSpec, 'NSCP', 'TEXT', smSystemScript);	if ( (err != noErr) && (err != dupFNErr))	{		ErrorHandler();		return false;	}	ERR_CHECK_RET(FSpOpenDF(idiSpec, fsRdWrPerm, &refNum), false);		// setup buffer to at least 8K	buf = NULL;	buf = NewPtrClear(kGenIDIFileSize);	if (!buf)	{		ErrorHandler();		return false;	}	compsDone = 0;	instChoice = gControls->opt->instChoice-1;		// loop through 0 to kMaxComponents	for(i=0; i<kMaxComponents; i++)	{		// general test: if component in setup type		if ( (gControls->cfg->st[instChoice].comp[i] == kInSetupType) &&			 (compsDone < gControls->cfg->st[instChoice].numComps) )		{ 			// if custom and selected, or not custom setup type			// add file to buffer			if ( ((instChoice == gControls->cfg->numSetupTypes-1) && 				  (gControls->cfg->comp[i].selected == true)) ||				 (instChoice < gControls->cfg->numSetupTypes-1) )			{				// get file number from STR# resource				GetIndString(pfnum, rIndices, compsDone+1);				fnum = PascalToC(pfnum);								// construct through concatenation [File<num>]\r				GetIndString(pkeybuf, rIDIKeys, sFile);				keybuf = PascalToC(pkeybuf);				ch = '[';				strncat(buf, &ch, 1);				strncat(buf, keybuf, strlen(keybuf));				strncat(buf, fnum, strlen(fnum));				DisposePtr(keybuf);								keybuf = NewPtrClear(2);				keybuf = "]\r";				strncat(buf, keybuf, strlen(keybuf));				if (keybuf)					DisposePtr(keybuf);				// write out \tdesc=				GetIndString(pkeybuf, rIDIKeys, sDesc);				keybuf = PascalToC(pkeybuf);				ch = '\t';												strncat(buf, &ch, 1);					// \t				strncat(buf, keybuf, strlen(keybuf));	// \tdesc				ch = '=';								// \tdesc=				strncat(buf, &ch, 1);				if (keybuf)					DisposePtr(keybuf);								// write out gControls->cfg->comp[i].shortDesc\r				HLock(gControls->cfg->comp[i].shortDesc);				strncat(buf, *gControls->cfg->comp[i].shortDesc, strlen(*gControls->cfg->comp[i].shortDesc));								HUnlock(gControls->cfg->comp[i].shortDesc);				ch = '\r';				strncat(buf, &ch, 1);							// iterate over gControls->cfg->comp[i].numURLs				for (j=0; j<gControls->cfg->comp[i].numURLs; j++)				{					// write out \tnumURLs+1= from STR# resource					GetIndString(pkeybuf, rIndices, j+2); // j+2 since 1-based idx, not 0-based					keybuf = PascalToC(pkeybuf);					ch = '\t';					strncat(buf, &ch, 1);					// \t					strncat(buf, keybuf, strlen(keybuf));	// \t<n>					ch = '=';					strncat(buf, &ch, 1);					// \t<n>=					if (keybuf)						DisposePtr(keybuf);										// write out gControls->cfg->comp[i].url[j]+archive\r					HLock(gControls->cfg->comp[i].url[j]);										strncat(buf, *gControls->cfg->comp[i].url[j], strlen(*gControls->cfg->comp[i].url[j]));					HUnlock(gControls->cfg->comp[i].url[j]);					HLock(gControls->cfg->comp[i].archive);					strncat(buf, *gControls->cfg->comp[i].archive, strlen(*gControls->cfg->comp[i].archive));					HUnlock(gControls->cfg->comp[i].archive);					ch = '\r';					strncat(buf, &ch, 1);				}				if (fnum)					DisposePtr(fnum);				compsDone++;			}		}		else if (compsDone == gControls->cfg->st[instChoice].numComps)			break;  	}					// terminate by entering Netscape Install section	GetIndString(pkeybuf, rIDIKeys, sNSInstall);	keybuf = PascalToC(pkeybuf);	ch = '[';	strncat(buf, &ch, 1);					// [	strncat(buf, keybuf, strlen(keybuf));	// [Netscape Install	if (keybuf)		DisposePtr(keybuf);		keybuf = NewPtrClear(2);	keybuf = "]\r";					strncat(buf, keybuf, strlen(keybuf));	// [Netscape Install]\r	if (keybuf)		DisposePtr(keybuf);		// write out \tcore_file=<filename>\r	AddKeyToIDI( sCoreFile, gControls->cfg->coreFile, buf );		// write out \tcore_dir=<dirname>\r	AddKeyToIDI( sCoreDir, gControls->cfg->coreDir, buf );		// write out \tno_ads=<boolean>\r	AddKeyToIDI( sNoAds, gControls->cfg->noAds, buf );		// write out \tsilent=<boolean>\r	AddKeyToIDI( sSilent, gControls->cfg->silent, buf );		// write out \texecution=<boolean>\r	AddKeyToIDI( sExecution, gControls->cfg->execution, buf );		// write out \tconfirm_install=<boolean>	AddKeyToIDI( sConfirmInstall, gControls->cfg->confirmInstall, buf );		// write buf to disk	count = strlen(buf);	ERR_CHECK_RET(FSWrite(refNum, &count, buf), false);		// close file	ERR_CHECK_RET(FSClose(refNum), false)		if (buf)		DisposePtr(buf);	return bSuccess;}