EssGetVariable

Retrieves the value of a substitution variable.

Syntax

ESS_FUNC_M EssGetVariable (hCtx, pVariable);
ParameterData TypeDescription

hCtx

ESS_HCTX_T

Context handle to the API.

pVariable

ESS_VARIABLE_T

The pointer to the structure containing the description of the specified substitution variable.

Return Value

If successful, EssGetVariable() returns the value of the substitution variable in the VarValue field of structure ESS_VARIABLE_T.

Example

/*
** ESS_GetVariable() gets the substitution variable value using
** the API function EssGetVariable.  
*/
ESS_FUNC_M
ESS_GetVariable (ESS_HCTX_T hCtx)
{
   ESS_FUNC_M      sts = ESS_STS_NOERR;
   ESS_VARIABLE_T Variable;
   printf("\n ***************************************");
   printf("\n **** An example of using EssGetVariable");
   printf("\n ***************************************");
    
   /********************************/
   /* Get the Value of QuarterName */
   /********************************/
   strcpy(Variable.VarName, "QuarterName"); 
   strcpy(Variable.Server,  "Local"); 
   strcpy(Variable.AppName, "Sample"); 
   strcpy(Variable.DbName,  "Basic");
   sts = EssGetVariable(hCtx, &Variable);
   if (sts == ESS_STS_NOERR)
   {
      printf("\n------- Substitution Variable 'QuarterName' Information \n");
      printf("Variable name    : %s\n",   Variable.VarName);
      printf("Server name      : %s\n",   Variable.Server);
      printf("Application name : %s\n",   Variable.AppName);
      printf("Database name    : %s\n",   Variable.DbName);
      printf("Variable value   : %s\n\n", Variable.VarValue);
   }
   /***************************************************************/
   /* Get the Value of MarketName at the level of the Server/App  */
   /***************************************************************/
   if (sts == ESS_STS_NOERR)
   {
     strcpy(Variable.VarName, "MarketName"); 
     strcpy(Variable.Server,  "Local"); 
     strcpy(Variable.AppName, "Sample"); 
     strcpy(Variable.DbName,  "");
     sts = EssGetVariable(hCtx, &Variable);
     if (sts == ESS_STS_NOERR)
     {
        printf("\n------- Substitution Variable 'MarketName' Information \n");
        printf("Variable name    : %s\n",   Variable.VarName);
        printf("Server name      : %s\n",   Variable.Server);
        printf("Application name : %s\n",   Variable.AppName);
        printf("Database name    : %s\n",   Variable.DbName);
        printf("Variable value   : %s\n\n", Variable.VarValue);
     }
   }
   /***********************************************************/
   /* Get the Value of MarketName at the level of the Server  */
   /***********************************************************/
   if (sts == ESS_STS_NOERR)
   {
     strcpy(Variable.VarName, "MarketName"); 
     strcpy(Variable.Server,  "Local"); 
     strcpy(Variable.AppName, ""); 
     strcpy(Variable.DbName,  "");
     sts = EssGetVariable(hCtx, &Variable);
     if (sts == ESS_STS_NOERR)
     {
        printf("\n------- Substitution Variable 'MarketName' Information \n");
        printf("Variable name    : %s\n",   Variable.VarName);
        printf("Server name      : %s\n",   Variable.Server);
        printf("Application name : %s\n",   Variable.AppName);
        printf("Database name    : %s\n",   Variable.DbName);
        printf("Variable value   : %s\n\n", Variable.VarValue);
     }
   }

   if (sts == ESS_STS_NOERR)
     printf("\n --> No Errors in EssGetVariable\n\n\n");
   else
     printf("\n --> Error in EssGetVariable number: %d\n\n\n", sts); 
   
   return (sts);
} /* End ESS_GetVariable */

Output

 ***************************************
 **** An example of using EssGetVariable
 ***************************************
------- Substitution Variable 'QuarterName' Information 
Variable name    : QuarterName
Server name      : Local
Application name : Sample
Database name    : Basic
Variable value   : Qtr2

------- Substitution Variable 'MarketName' Information 
Variable name    : MarketName
Server name      : Local
Application name : Sample
Database name    : 
Variable value   : East

------- Substitution Variable 'MarketName' Information 
Variable name    : MarketName
Server name      : Local
Application name : 
Database name    : 
Variable value   : Market
 --> No Errors in EssGetVariable

See Also