cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
spiderlily
Occasional contributor

Example of FeatureGetCostEx and ConvertSizeToUnits

Jump to solution

I was asked to write an installer that will allow the user to install data in a different location than the software.  So I'm trying to check the user's chosen path to make sure there is enough space there. 

For some reason the following code produces an error on the "ConvertSizeToUnits" line, stating "numeric variable required," error code C8046. 

Does anyone have a working example of this?  Can you see anything wrong?  I've tried this with and without assigning variables to hold the result of the FeatureGetCostEx and ConvertSizeToUnits functions.  I hope this has a simple answer.

Dlg_SdAskDestPath_data:
	szTitle = "Choose Data Folder";
	szMsg = "Choose where to install data for %P.";
	//Initialize directories to DATA_DIR global variable, which is basically C:\\Users\\Public\\myapp_data
	svDataDir = DATA_DIR;
	nDataDirResult = SdAskDestPath(szTitle, szMsg, svDataDir, 0);
	if (nDataDirResult = BACK) then
		goto Dlg_SetupType2;
	else
		// Check disk space at the data destination path
		nDataSpace = GetDiskSpaceEx (svDataDir, MBYTES);
		//nDataSpaceReq = FeatureGetCostEx (MEDIA, "Data Files", svDataDir, nvCostHigh, nvCostLow);
		FeatureGetCostEx (MEDIA, "Data Files", svDataDir, nvCostHigh, nvCostLow);
		nConv = ConvertSizeToUnits (nvCostHigh, nvCostLow, BYTES, nvCostMBHigh, nvCostMBLow, MBYTES); // ---> Error flags this line
		nDataSpaceReqMB = nvCostMBHigh + nvCostMBLow;
		if (nDataSpaceReqMB > nDataSpace) then
			MessageBox(svDataDir + " does not have enough space to install Data Files. Please choose a different location with at least " + nDataSpaceReq + " MB free." , SEVERE);
			goto Dlg_SdAskDestPath_data;
		endif;
		// If it gets this far, it passes the tests, so
		DATA_DIR = svDataDir;
	endif;

 

  

 

0 Kudos
1 Solution

Accepted Solutions
Flexera banna_k
Flexera

Re: Example of FeatureGetCostEx and ConvertSizeToUnits

Jump to solution

Hi @spiderlily ,

Check the below link for the sample code, and pass the last parameter in a variable:

nUnitsTarget = MBYTES;

https://helpnet.flexerasoftware.com/installshield19helplib/Subsystems/installshield19langref/helplib...

 

And in the message box, use the conversion function to convert the NUMBER to string before doing the concatenation. 

https://helpnet.flexerasoftware.com/installshield22helplib/Subsystems/installshield22langref/helplib...

 

2 Replies
Flexera banna_k
Flexera

Re: Example of FeatureGetCostEx and ConvertSizeToUnits

Jump to solution

Hi @spiderlily ,

Check the below link for the sample code, and pass the last parameter in a variable:

nUnitsTarget = MBYTES;

https://helpnet.flexerasoftware.com/installshield19helplib/Subsystems/installshield19langref/helplib...

 

And in the message box, use the conversion function to convert the NUMBER to string before doing the concatenation. 

https://helpnet.flexerasoftware.com/installshield22helplib/Subsystems/installshield22langref/helplib...

 

spiderlily
Occasional contributor

Re: Example of FeatureGetCostEx and ConvertSizeToUnits

Jump to solution

Thank you so much!  That helped.  Now on to other errors...

0 Kudos