4.8.3.70. GETSTRINGWC

The GETSTRINGWC subroutine returns a pointer of the parametric string, in the wide character type, which corresponds to the ID of string.

Table 4.185 Function Name

Language type

Subroutine

C/C++

GetStringWC(IDstring, &string, &nstring, &error)

The user can perform differently for each entity.

Table 4.186 Parameter information

Variable Name

Size

Description

IDstring

int

The input variable, the RMD id of string entity have to be set.

string

char

The output variable, the string value is returned according to the RMD id of string entity.

nstring

int

The input variable, the nstring have to be set with the size of string.

error

int

The output variable, if there is value for this string, this value is set with “TRUE”.

Listing 4.92 C/C++ code for GETSTRINGWC
 #include "stdafx.h"
 #include "DllFunc.h"
 #include <stdio.h>
 #include <stdlib.h>

 int fCloseProgram = 0;
 int fInitial[2] = { 1, 1 };
 int nString[2] = { 0 };
 char* pString[2];
 FILE* pFileOutput[2];

 RecurDynUserSubRoutinewizard1_API void __cdecl axial_force
 (double time, double upar[], int npar, int jflag, int iflag, double* result)
 {
   using namespace rd_syscall;
   // Parameter Information
   //   time: Simulation time of RD/Solver
   //   upar: Parameters defined by user
   //   npar: Number of user parameters
   //   jflag: When RD/Solver evaluates a Jacobian, the flag is true.
   //   iflag: When RD/Solver initializes arrays, the flag is true.
   //   result: Returned value

   // User statement
   // Local Varialbe Definition
   int mkid[3], errflg, akispl_id;
   double disp, value[3], stepsize;
   int finish, convergenceFlag;
   char sName[256];
   int nName;
   int iString;
   int szTCHAR;
   unsigned long long szAllocated;
   int err = 0;
   char FileName[256][2];

   if( fCloseProgram == 1)
   {
     return;
   }

   getcurrententityname(sName,&nName,&errflg);
   getstepsize( &stepsize );
   getfinishflag( &finish );
   getconvergenceflag( &convergenceFlag);


   // Assign Impact Parameters
   mkid[0] = (int) upar[0];
   mkid[1] = (int) upar[1];
   mkid[2] = (int) upar[2];
   akispl_id = (int) upar[3];
   iString= (int) upar[4];; // 0 or 1

   if(fInitial[iString] == 1)
   {
     fInitial[iString] = 0;

     getstringlength(iString,&nString[iString],&errflg);
     szTCHAR = sizeof(char);
     szAllocated = (unsigned long long)nString[iString]*szTCHAR;
     pString[iString] = (char*)malloc(szAllocated);

     getstring(iString,pString[iString],&nString[iString],&errflg);
     sprintf_s( FileName[iString], 255 ,"%s.txt",pString[iString]);
     err = fopen_s(&pFileOutput[iString], FileName[iString], "w");
   }

   if(finish == 1)
   {
     fCloseProgram = 1;
     free(pString[iString]);
     fclose(pFileOutput[iString]);
   }
   else
   {
     getstring(iString,pString[iString],&nString[iString],&errflg);
     fprintf(pFileOutput[iString],"%s\n",pString[iString]);
   }

   if(convergenceFlag == 1)
   {
     convergenceFlag = 0;
   }

   if( strncmp(sName,"Axial1",nName) == 0)
   {
     // Call the Auxiliary subroutines for Calculation
     sysfnc("DX", mkid, 3, &disp, &errflg);
     rd_akispl(disp, 0, akispl_id, 0, value, &errflg);
   }
   else
   {
     // Call the Auxiliary subroutines for Calculation
     sysfnc("DY", mkid, 3, &disp, &errflg);
     rd_akispl(disp, 0, akispl_id, 0, value, &errflg);
   }

   // Assign the Returned Value
   *result = value[0];
 }