SimApi Control getCommandLineParameterValue 1

From SIMboxWiki
Revision as of 17:44, 16 March 2010 by Ofirs (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search



Icon attributes.pngstatic bool SimApi::Control::getCommandLineParameterValue(CCHAR_A *parameterName, CHAR_A *buffer, int &size)

    Description

    Gets the value of a command line parameter ANSI.

    Parameters

    parameterName - The name of the command line parameters for which the function will return the value.
    buffer - The value of the command line parameter.
    size - The buffer size. This integer will be initialized with the value buffer size.

    Return

    Type: bool   Description: True, if suceeded; Otherwise, false.

    Remarks
    

This function is typically used when a plugin (plg file) gets some information from the simulation command line. Example: A plugin that recieves a file path in order to export some data during a session.


    Code Sample
    

//This function sets new rate according to a command line parameter.      
//The addition to the command line parameters is : "/rate 4"
//SetSimulationRateFromCommandLine can be called in the init() function of an Extension SIMbox Project.            
private void SetSimulationRateFromCommandLine()
{
	STRING param = "rate";
        CHAR_A value[1024];
        int size = 0;

        getCommandLineParameterValue(param, value, size);
        
	STRING valueStr(value);
        int rate = SimUtil::StringToInt(valueStr);
        
	//if the rate value is in the right range
        if(rate >= 1 &amp;&amp; rate < 16)
        { 
        	//set the rate with the new command line rate.
		SimApi::Control::SetRate(rate);
        }
}


    See Also

     getCommandLineParameterValue

     addCommandLineParameter