API Help
EPLAN API / User Guide / API Framework / Scripts / Simple script with parameters
In This Topic
    Simple script with parameters
    In This Topic

    The script functionality does also accept parameters. However this only makes sense if a parameter can be passed to the script, when it is started. This can be done by invoking EPLAN via the command line: 

                                 

    W3u.exe ExecuteScript /ScriptFile:"C:\Program Files\EPLAN\EPLAN\Basic\Scripts\EPLAN\SimpleScriptWithParameters.cs" /Param1:Hello /Param2:EPLAN /Param3:" API developer!" 

     

    When starting EPLAN via command line, in order to run a script, the first parameter is the name of the action to execute. "ExecuteScript" is the action for running scripts. This action takes the parameter "ScriptFile" which specifies the name of the script file to run. Any further parameter (Param1, Param2, Param3) will be passed to the start function of the script.

    Example

    In the following example, the script (the script function) requires 3 string parameters Param1, Param2 and Param3: 

     

    public class SimpleScriptWithParameters
     {
        [Start]
         public bool FunctionWithParameters(String Param1, String Param2, String Param3)
         {
            new Decider().Decide(EnumDecisionType.eOkDecision,  Param1 + Param2 + Param3 , "SimpleScriptWithPars", EnumDecisionReturn.eOK, EnumDecisionReturn.eOK);
             return true;
        }
     }
    
    Public Class SimpleScriptWithParameters
    
       <Start>  _
       Public Function FunctionWithParameters(ByVal Param1 As String, ByVal Param2 As String, _
                                                ByVal Param3 As String) as Boolean
    Dim message as Decider = New Decider
          message.Decide(EnumDecisionType.eOkDecision,  Param1 + Param2 + Param3 , "SimpleScriptWithPars", EnumDecisionReturn.eOK, EnumDecisionReturn.eOK)
          Return True
       End Sub 'FunctionWithParameters
    End Class 'SimpleScriptWithParameters
    
                       

     

    It is important, that the identifiers (Param1, Param2, Param3) are exactly matching in the command line and in the function! 

     

    Using this feature, you can extend the scope of the EPLAN command line by your own parameters. If you need to call some API functionality via command line, just create a script. The start function of this script may take parameters and can call other functions with these parameters.