Example #1
0
void smartschoolTest::testSaveUser() {
  y::ldap::server Server;
  y::ldap::account & a = Server.getAccount(UID("unitTest"));
  if(!a.isNew()) {
    CPPUNIT_ASSERT(false);
  }
  a.role(ROLE(ROLE::NONE));
  a.uid(UID("unitTest"));
  a.gender(GENDER(GENDER::MALE));
  a.street(STREET("my street"));
  a.houseNumber(HOUSENUMBER(42));
  a.houseNumberAdd(HOUSENUMBER_ADD("a"));
  a.birthDay(DATE(DAY(9), MONTH(8), YEAR(1972)));
  a.wisaID(WISA_ID(111111111));
  a.password(PASSWORD("ABcd!eGf"));
  a.ssPassword("ABcd!eGf");
  a.cn(CN("unit"));
  a.sn(SN("test"));
  a.birthPlace(BIRTHPLACE("brussels"));
  a.postalCode(POSTAL_CODE("1000"));
  a.city(CITY("brussels"));
  a.country(COUNTRY("belgie"));
  a.mail(MAIL("*****@*****.**"));
  
  // role is not set!
  if(y::Smartschool().saveUser(a)) {
    CPPUNIT_ASSERT(false);
  }
  
  a.role(ROLE(ROLE::STUDENT));
  if(!y::Smartschool().saveUser(a)) {
    CPPUNIT_ASSERT(false);
  }
  
}
Example #2
0
//transform dividends
STDMETHODIMP CEtsHolidayAtom::TransformDividends(SAFEARRAY **psaDates, LONG nCount, SAFEARRAY **psaTDates, LONG *pnTCount)
{
	if (!pnTCount || !psaDates || !psaTDates) return E_POINTER;
	
	HRESULT	hr = S_OK;

	try
	{
		*pnTCount = 0;
		if (nCount > 0)
		{
			DOUBLE	*pdDates = NULL;

			LongVector	lvDates;

			if( *psaTDates )
			{
				::SafeArrayDestroy(*psaTDates);
				*psaTDates = NULL;
			}

			if( SUCCEEDED(hr = ::SafeArrayAccessData(*psaDates, reinterpret_cast<void**>(&pdDates))) )
			{
				DATE	dtRealDate;
				for(int i = 0; i < nCount; i++)
				{
					GetPreviousWorkingDate(DATE(pdDates[i] * 365.0), &dtRealDate);
					lvDates.push_back( static_cast<LONG>(floor(dtRealDate)) );
				}
				::SafeArrayUnaccessData(*psaDates);
				
				*pnTCount = static_cast<LONG>(lvDates.size());
				if (*pnTCount > 0)
				{
					LPSAFEARRAY pDates = SafeArrayCreateVector(VT_R8, 0, *pnTCount);
					::SafeArrayLock(pDates);
					LPVOID lpDateData = NULL;
					::SafeArrayAccessData(pDates, &lpDateData);

					DOUBLE * pdDates =	 reinterpret_cast<DOUBLE *>(lpDateData);

					for(long i = 0; i< *pnTCount; i++)
					{
						pdDates[i] = lvDates[i]/365.0;
					}

					::SafeArrayUnaccessData(pDates);
					::SafeArrayUnlock(pDates);
					
					*psaTDates = pDates;
				}
			}
		}
	}
	catch (...)
	{
		return E_FAIL;
	}
	return S_OK;
}
Example #3
0
int main(int argc, char **argv)
{
	int customer_id = 382018, rating_date = 382;
	printf("%d, %d\n", customer_id, rating_date);
	RATING r = MAKE_RATING(customer_id, rating_date);
	printf("%d, %d\n", CUST(r), DATE(r));
}
Example #4
0
File: migd.c Project: npe9/sprite
static int
CreateGlobal()
{
    int pid;
    
    if (migd_Debug > 2) {
	fprintf(stderr, "CreateGlobal -\n");
    }

    if (migd_DontFork) {
	fprintf(stderr, "CreateGlobal - becoming master; start a new child.\n");
	pid = 0;
    } else {
	pid = fork();
	if (pid < 0) {
	    fprintf(stderr, "CreateGlobal - couldn't fork\n");
	    return(-1);
	}
    }
    if (pid > 0) {
	/*
	 * Give the child a chance to set things up.  We should be awakened
	 * by a signal if the child should exit prematurely.
	 */
	sleep(5);
	return(0);
    }

    /*
     * We are the child, and will try to become the global master.
     */
    (void) signal(SIGCHLD, SIG_DFL);
    MigPdev_CloseAllStreams();

    if (Global_Init() < 0) {
	exit(1);
    }
	
    if (migd_Debug > 0) {
	fprintf(stderr, "CreateGlobal - we are the global master, pid %x\n",
	       getpid());
    }

    Migd_HandleRequests();

    /*
     * If we reach this point we were signalled or in some other way
     * told to exit.
     */

    Global_End();
    DATE();
    exit(0);

#ifdef lint
    return(0); /* keep lint happy */
#endif
}
Example #5
0
y::ldap::account::account(y::ldap::server * server) :
  server(server),
  // var          name in ldap          type and init    is int?      
  _uidNumber     (TYPE_UIDNUMBER      , UID_NUMBER (0 )),
  _uid           (TYPE_UID            , UID        ("")),
  _dn            ("DN"                , DN         ("")),
  _cn            (TYPE_CN             , CN         ("")),
  _sn            ("sn"                , SN         ("")),
  _fullName      ("displayName"       , FULL_NAME  ("")),
  _homeDir       ("homeDirectory"     , HOMEDIR    ("")),
  _wisaID        ("wisaID"            , WISA_ID    (0 )),
  _wisaName      (TYPE_WISANAME       , WISA_NAME  ("")),
  _mail          ("mail"              , MAIL       ("")),
  _mailAlias     ("mailAlias"         , MAIL_ALIAS ("")),
  _birthDay      ("birthday"          , DATE(DAY(1), MONTH(1), YEAR(1))),
  _password      ("gMailPassword"     , PASSWORD   ("")),
  _role          ("schoolRole"        , ROLE(ROLE::NONE)),
  _groupID       ("gidNumber"         , GID_NUMBER (0 )),
  _schoolClass   ("class"             , SCHOOLCLASS("")),
  _classChange   ("classChangeDate"   , DATE(DAY(1), MONTH(1), YEAR(1))),
  _birthPlace    ("placeOfBirth"      , BIRTHPLACE ("")),
  _gender        ("gender"            , GENDER(GENDER::MALE) ),
  _adminGroup    ("adminGroupID"      , ADMINGROUP (0 )),
  _registerID    ("nationalRegisterID", REGISTER_ID("")),
  _nationality   ("nationality"       , NATION     ("")),
  _stemID        ("stemID"            , STEM_ID    (0 )),
  _schoolID      ("schoolID"          , SCHOOL_ID  (0 )),   
  _houseNumber   ("houseNumber"       , HOUSENUMBER(0 )),
  _houseNumberAdd("houseNumberAdd"    , HOUSENUMBER_ADD("")  ),
  _city          ("location"          , CITY       ("")),
  _postalCode    ("postalCode"        , POSTAL_CODE("")),
  _street        ("street"            , STREET     ("")),
  _country       ("co"                , COUNTRY    ("")),

  _new(true),
  _hasKrbName(false),
  _hasSchoolPersonClass(false),
  _importStatus(WI_NOT_ACCOUNTED),
  _flaggedForRemoval(false)
  {}
Example #6
0
int main(int argc, char **argv)
{
	int i = 0;
	FILE* fh;
	UINT customer_id = 382018, rating_date = 382;
	for (i = 0; i < NUM_RATINGS; i++) {
		r[i] = MAKE_RATING(customer_id, rating_date);
		customer_id += 1;
		rating_date += 3;
	}
	for (i = 0; i < NUM_RATINGS; i++) {
		printf("%u, %u\n", CUST(r[i]), DATE(r[i]));
	}
	fh = fopen("ratings.dat", "wb");
	fwrite(r, sizeof(RATING), NUM_RATINGS, fh);
	fclose(fh);
}
Example #7
0
void print_all() {
	UINT movie_id = 1, rating = 1, customer_id = 0, rating_date = 0;
	int i = 0;
	for (i = 0; i < NUM_SLOTS; i++) {
		if (r[i] == 0) {
			if (rating >= 5) {
				movie_id++;
				rating = 1;
			}
			else {
				rating++;
			}
		}
		else {
			customer_id = CUST(r[i]);
			rating_date = DATE(r[i]);
			//printf("%u, %u, %u, %u\n", movie_id, rating, customer_id, rating_date);
		}
	}
	printf("printed all\n");
}
Example #8
0
void
randomCons(char *buf, sccs *s, ser_t d)
{
	u32	date;
	u32	crc1, crc2;
	char	*item;

	/*
	 * We don't want to hash realuser or realhost as that would
	 * make prevent these random bits from being stable.
	 */
	item = USER(s, d);	/* user or user/realuser */
	crc1 = crc32c(0, item, strcspn(item, "/"));
	item = HOSTNAME(s, d);	/* host or host/realhost */
	crc1 = crc32c(crc1, item, strcspn(item, "/["));

	crc2 = crc32c(0, PATHNAME(s, d), strlen(PATHNAME(s, d)));
	date = DATE(s, d);
	crc2 = crc32c(crc2, &date, sizeof(date));
	sprintf(buf, "%x%x", crc1, crc2);
}
Example #9
0
JNIEXPORT jdouble JNICALL Java_be_derycke_pieter_com_OleDate_toDouble
	(JNIEnv* env, jobject obj)
{
	jclass cls;
	jmethodID mid;
	int year, month, day, hour, minute, second;

	cls = env->GetObjectClass(obj);

	//jaar
	mid = env->GetMethodID(cls, "getYear", "()I");
	year = env->CallIntMethod(obj, mid);

	//maand
	mid = env->GetMethodID(cls, "getMonth", "()I");
	month = env->CallIntMethod(obj, mid);

	//dag
	mid = env->GetMethodID(cls, "getDate", "()I");
	day = env->CallIntMethod(obj, mid);

	//uren
	mid = env->GetMethodID(cls, "getHours", "()I");
	hour = env->CallIntMethod(obj, mid);

	//minuten
	mid = env->GetMethodID(cls, "getMinutes", "()I");
	minute = env->CallIntMethod(obj, mid);

	//seconden
	mid = env->GetMethodID(cls, "getSeconds", "()I");
	second = env->CallIntMethod(obj, mid);

	COleDateTime date(year, month, day, hour, minute, second);
	
	return DATE(date);
}
Example #10
0
void y::ldap::account::clear() {
  _new = true;
  _hasKrbName = false;
  _hasSchoolPersonClass = false;
  _uidNumber     .reset(UID_NUMBER (0 ));
  _uid           .reset(UID        (""));
  _dn            .reset(DN         (""));
  _cn            .reset(CN         (""));
  _sn            .reset(SN         (""));
  _fullName      .reset(FULL_NAME  (""));
  _homeDir       .reset(HOMEDIR    (""));
  _wisaID        .reset(WISA_ID    (0 ));
  _wisaName      .reset(WISA_NAME  (""));
  _mail          .reset(MAIL       (""));
  _mailAlias     .reset(MAIL_ALIAS (""));
  _birthDay      .reset(DATE(DAY(1), MONTH(1), YEAR(1)));
  _password      .reset(PASSWORD   (""));
  _role          .reset(ROLE(ROLE::NONE));
  _groupID       .reset(GID_NUMBER (0 ));
  _schoolClass   .reset(SCHOOLCLASS(""));
  _birthPlace    .reset(BIRTHPLACE (""));
  _gender        .reset(GENDER(GENDER::MALE));
  _adminGroup    .reset(ADMINGROUP (0 ));
  _registerID    .reset(REGISTER_ID(""));
  _nationality   .reset(NATION     (""));
  _stemID        .reset(STEM_ID    (0 ));
  _schoolID      .reset(SCHOOL_ID  (0 ));
  _street        .reset(STREET     (""));  
  _houseNumber   .reset(HOUSENUMBER(0 ));
  _houseNumberAdd.reset(HOUSENUMBER_ADD(""));
  _city          .reset(CITY       (""));
  _postalCode    .reset(POSTAL_CODE(""));
  _country       .reset(COUNTRY    (""));
  _ssPassword.clear();
  _flaggedForRemoval = false;
}
Example #11
0
void yearbookDownload::generatePDF() {
  std::fstream content;
  content.open("yearbook_latex/content.tex", std::ios::out | std::ios::trunc);
  
  db->loadAllUsers("classgroup", true);
  
  string currentGroup;
  
  container<yearbookDB::entry> & entries = db->getEntries();
  
  for(int i = 0; i < entries.elms(); i++) {
    yearbookDB::entry & currentEntry = entries[i];
    
    if (currentGroup != currentEntry.group) {
      // new group
      currentGroup = currentEntry.group;
      string groupName = currentEntry.group;
      for (int i = 0; i < db->getReplacements().elms(); i++) {
        if(db->getReplacements()[i]["original"].asString() == currentEntry.group) {
          groupName = db->getReplacements()[i]["replacement"].asString();
        }
      }
      
      std::string groupImage = "Pictures/chapter_head_2";
      for(int i = 0; i < db->getGroupImages().elms(); i++) {
        if(db->getGroupImages()[i]["groupName"].asString() == currentGroup) {
          groupImage = "../" + db->getGroupImages()[i]["imageName"].asString().utf8();
          boost::algorithm::erase_last(groupImage, ".png");
          break;
        }
      }
      content << std::endl << "\\chapterimage{" << groupImage << "}" << std::endl;
      content << std::endl << "\\chapter*{" << groupName << "}" << std::endl;
      content << std::endl << "\\chaptermark{" << groupName << "}" << std::endl;
      content << std::endl << "\\addcontentsline{toc}{chapter}{" << groupName << "}" << std::endl;
      
      content << std::endl << "\\centering" << std::endl;
      content << "\\begin{varwidth}{\\textwidth}" << std::endl;
      content << "\\begin{itemize}" << std::endl;
      content << "\\Large" << std::endl;
      
      for (int j = i; j < db->getEntries().elms(); j++) {
        yearbookDB::entry & tempEntry = db->getEntries()[j];
        if(currentGroup != tempEntry.group) {
          break;
        }
 
        content << "\\item " << tempEntry.name << " " << tempEntry.surname << std::endl;
        
      }
      content << "\\end{itemize}" << std::endl;
      content << "\\end{varwidth}" << std::endl;
      content << std::endl << "\\newpage" << std::endl;
    }
    
    content << std::endl << "\\section*{\\sectionformat " << currentEntry.name << " " << currentEntry.surname << "}" << std::endl;
    content << "\\hrule\\bigskip" << std::endl;
    
    content << std::endl << "\\centering" << std::endl;
    content << "\\begin{varwidth}{\\textwidth}" << std::endl;
    content << "\\begin{itemize}" << std::endl;
    DATE date = DATE(DAY(currentEntry.birthday.day()), MONTH(currentEntry.birthday.month()), YEAR(currentEntry.birthday.year()));
    content << std::endl << "\\bday \\Large " << date.get() << std::endl;
    content << "\\end{itemize}" << std::endl;
    content << "\\end{varwidth}" << std::endl;
    
    content << std::endl << "\\bigskip" << std::endl;
    
    std::string mail = currentEntry.mail.utf8();
    std::replace(mail.begin(), mail.end(), '%', ' ');
    
    content << "\\begin{varwidth}{\\textwidth}" << std::endl;
    content << "\\begin{itemize}" << std::endl;
    content << std::endl << "\\mail \\Large \\detokenize{" << mail << "}" << std::endl;
    content << "\\end{itemize}" << std::endl;
    content << "\\end{varwidth}" << std::endl;
    
    content << std::endl << "\\bigskip" << std::endl;
    std::string picture;
    if (currentEntry.photo.size() > 0) {
      
      picture = "../" + currentEntry.photo.utf8();
      boost::algorithm::replace_first(picture, "userImages", "yearbookImages");
      boost::algorithm::erase_last(picture, ".png");
    } else {
      picture = "Pictures/placeholder";
    }
    content << std::endl << "\\includegraphics[height=7cm]{" << picture << "}" << std::endl;
    content << std::endl << "\\bigskip" << std::endl;
    
    content << std::endl << "\\justifying" << std::endl;
    
    content << std::endl << db->getQuestion(0) << std::endl;
    content << std::endl << "\\begin{exercise}" << std::endl;
    content << std::endl << "\\detokenize{" << currentEntry.answer1 << "}" << std::endl;
    content << std::endl << "\\end{exercise}" << std::endl;
    
    content << std::endl << db->getQuestion(1) << std::endl;
    content << std::endl << "\\begin{exercise}" << std::endl;
    content << std::endl << "\\detokenize{" << currentEntry.answer2 << "}" << std::endl;
    content << std::endl << "\\end{exercise}" << std::endl;
    
    content << std::endl << db->getQuestion(2) << std::endl;
    content << std::endl << "\\begin{exercise}" << std::endl;
    content << std::endl << "\\detokenize{" << currentEntry.answer3 << "}" << std::endl;
    content << std::endl << "\\end{exercise}" << std::endl;
    
    content << std::endl << db->getQuestion(3) << std::endl;
    content << std::endl << "\\begin{exercise}" << std::endl;
    content << std::endl << "\\detokenize{" << currentEntry.answer4 << "}" << std::endl;
    content << std::endl << "\\end{exercise}" << std::endl;
    content << std::endl << "\\newpage" << std::endl;
  }
  
  content.close();
  
  string cmd;
	cmd =  "export PATH=\"$PATH:/usr/sbin:/usr/bin:/sbin:/bin\"; "; 
	cmd += "cd yearbook_latex; ";
  cmd += "xelatex main; cd ..;";
  cmd.execute();
  cmd.execute();
  
  downloadFile->setFileName("yearbook_latex/main.pdf");
  downloadFile->setMimeType("application/pdf");
  downloadAnchor->setLink(Wt::WLink(downloadFile));
  downloadTitle->show();
  downloadContainer->show(); 
}
void ATimeControl::ESGet(const AString& sPath,AUI_ES_VALUE_INTF* pValue)
{
	if( pValue == NULL ) return;
	base_class::ESGet(sPath,pValue);
	if( sPath == L"time" ) pValue->SetDouble( (double)GetTime().operator DATE() );
}
Example #13
0
/*!
  \param Func
*/
xbShort xbExpn::ProcessFunction( char * Func )
{
/* 1 - pop function from stack
   2 - verify function name and get no of parms needed 
   3 - verify no of parms >= remainder of stack
   4 - pop parms off stack
   5 - execute function
   6 - push result back on stack
*/


  char   *buf = 0;
  xbExpNode *p1, *p2, *p3, *WorkNode, *FuncNode;
  xbShort  ParmsNeeded,len;
  char   ptype = 0;  /* process type s=string, l=logical, d=double */
  xbDouble DoubResult = 0;
  xbLong   IntResult = 0;
  FuncNode = (xbExpNode *) Pop();

  ParmsNeeded = GetFuncInfo( Func, 1 );

  if( ParmsNeeded == -1 ) {
    return XB_INVALID_FUNCTION;
  }
  else {
    ParmsNeeded = 0;
    if( FuncNode->Sibling1 ) ParmsNeeded++;
    if( FuncNode->Sibling2 ) ParmsNeeded++;
    if( FuncNode->Sibling3 ) ParmsNeeded++;
  }

  if( ParmsNeeded > GetStackDepth())
    return XB_INSUFFICIENT_PARMS;

  p1 = p2 = p3 = NULL;
  if( ParmsNeeded > 2 ) p3 = (xbExpNode *) Pop(); 
  if( ParmsNeeded > 1 ) p2 = (xbExpNode *) Pop(); 
  if( ParmsNeeded > 0 ) p1 = (xbExpNode *) Pop(); 
  memset( WorkBuf, 0x00, WorkBufMaxLen+1);

  if( strncmp( Func, "ABS", 3 ) == 0 ) {  
    ptype = 'd';
    DoubResult = ABS( GetDoub( p1 ));
  }
  else if( strncmp( Func, "ASC", 3 ) == 0 ) {  
    ptype = 'd';
    DoubResult = ASC( p1->StringResult );
  }
  else if( strncmp( Func, "AT", 2 ) == 0 ) {  
    ptype = 'd';
    DoubResult = AT( p1->StringResult, p2->StringResult );
  }
  else if( strncmp( Func, "CDOW", 4 ) == 0 ) {  
    ptype = 's';
    buf = CDOW( p1->StringResult );
  }
  else if( strncmp( Func, "CHR", 3 ) == 0 ) {  
    ptype = 's';
    buf = CHR( GetInt( p1 ));
  }
  else if( strncmp( Func, "CMONTH", 6 ) == 0 ) {  
    ptype = 's';
    buf = CMONTH( p1->StringResult );
  }
  else if( strncmp( Func, "CTOD", 4 ) == 0 ) {  
    ptype = 's';
    buf = CTOD( p1->StringResult );
  }
  else if( strncmp( Func, "DATE", 4 ) == 0 ) {  
    ptype = 's';
    buf = DATE();
  }
  else if( strncmp( Func, "DAY", 3 ) == 0 ) {  
    ptype = 'd';
    DoubResult = DAY( p1->StringResult );
  }
  else if( strncmp( Func, "DESCEND", 7 ) == 0 && p1->ExpressionType == 'C' ) {  
    ptype = 's';
    buf = DESCEND( p1->StringResult.c_str() );
  }
  else if( strncmp( Func, "DESCEND", 7 ) == 0 && p1->ExpressionType == 'N' ) {  
    ptype = 'd';
    DoubResult = DESCEND( GetDoub( p1 ));
  }
  else if( strncmp( Func, "DESCEND", 7 ) == 0 && p1->ExpressionType == 'D' ) {  
    xbDate d( p1->StringResult );
    ptype = 'd';
    DoubResult = DESCEND( d );
  }
  else if( strncmp( Func, "DOW", 3 ) == 0 ) {
    ptype = 'd';
    DoubResult = DOW( p1->StringResult );
  }
  else if( strncmp( Func, "DTOC", 4 ) == 0 ) {  
    ptype = 's';
    buf = DTOC( p1->StringResult );
  }
  else if( strncmp( Func, "DTOS", 4 ) == 0 ) {  
    ptype = 's';
    buf = DTOS( p1->StringResult );
  }
  else if( strncmp( Func, "EXP", 3 ) == 0 ) {  
    ptype = 'd';
    DoubResult = EXP( GetDoub( p1 ));
  }
  else if( strncmp( Func, "IIF", 3 ) == 0 ){
    ptype = 's';
    buf = IIF( p1->IntResult, p2->StringResult, p3->StringResult );
  }
  else if( strncmp( Func, "INT", 3 ) == 0 ) {  
    ptype = 'd';
    DoubResult = INT( GetDoub( p1 ));
  }
  else if( strncmp( Func, "ISALPHA", 7 ) == 0 ) {  
    ptype = 'l';
    IntResult = ISALPHA( p1->StringResult );
  }
  else if( strncmp( Func, "ISLOWER", 7 ) == 0 ) {  
    ptype = 'l';
    IntResult = ISLOWER( p1->StringResult );
  }
  else if( strncmp( Func, "ISUPPER", 7 ) == 0 ) {  
    ptype = 'l';
    IntResult = ISUPPER( p1->StringResult );
  }
  else if( strncmp( Func, "LEN", 3 ) == 0 ) {  
    ptype = 'd';
    DoubResult = LEN( p1->StringResult );
  }
  else if( strncmp( Func, "LEFT", 4 ) == 0 ) {  
    ptype = 's';
    buf = LEFT( p1->StringResult, INT( p2->DoubResult ));
  }
  else if( strncmp( Func, "LTRIM", 5 ) == 0 ) {  
    ptype = 's';
    buf = LTRIM( p1->StringResult );
  }  
  else if( strncmp( Func, "LOG", 3 ) == 0 ) {  
    ptype = 'd';
    DoubResult = LOG( GetDoub( p1 ));
  }  
  else if( strncmp( Func, "LOWER", 5 ) == 0 ) {  
    ptype = 's';
    buf = LOWER( p1->StringResult );
  }  
  else if( strncmp( Func, "MAX", 3 ) == 0 ) {  
    ptype = 'd';
    DoubResult = MAX( GetDoub( p1 ), GetDoub( p2 ));
  }  
  else if( strncmp( Func, "MIN", 3 ) == 0 ) {  
    ptype = 'd';
    DoubResult = MIN( GetDoub( p1 ), GetDoub( p2 ));
  }  
  else if( strncmp( Func, "MONTH", 5 ) == 0 ) {  
    ptype = 'd';
    DoubResult = MONTH( p1->StringResult );
  } 

  else if( strncmp( Func, "RECNO", 5 ) == 0 )
  {
    ptype = 'd';
    DoubResult = RECNO( FuncNode->dbf );
  }

  else if( strncmp( Func, "REPLICATE", 9 ) == 0 ) {
    ptype = 's';
    buf = REPLICATE( p1->StringResult, GetInt( p2 ));
  }
  else if( strncmp( Func, "RIGHT", 5 ) == 0 ) {
    ptype = 's';
    buf = RIGHT( p1->StringResult, GetInt( p2 ));
  }
  else if( strncmp( Func, "RTRIM", 5 ) == 0 ) {  
    ptype = 's';
    buf = RTRIM( p1->StringResult );
  }  
  else if( strncmp( Func, "SPACE", 5 ) == 0 ) {  
    ptype = 's';
    buf = SPACE( INT( GetDoub( p1 )));
  }
  else if( strncmp( Func, "SQRT", 4 ) == 0 ) {  
    ptype = 'd';
    DoubResult = SQRT( GetDoub( p1 ));
  }
  else if( strncmp( Func, "STRZERO", 7 ) == 0 && ParmsNeeded == 1 ) {
    ptype = 's';
    buf = STRZERO( p1->StringResult );
  }   
  else if( strncmp( Func, "STRZERO", 7 ) == 0 && ParmsNeeded == 2 ) {
    ptype = 's';
    buf = STRZERO( p1->StringResult, GetInt( p2 ));
  }   
  else if( strncmp( Func, "STRZERO", 7 ) == 0 && ParmsNeeded == 3 ) {
    ptype = 's';
    buf = STRZERO( p1->StringResult, GetInt( p2 ), GetInt( p3 ));
  }   

  else if( strncmp( Func, "STR", 3 ) == 0 && p3 ) {
    ptype = 's';
    if(p1->ExpressionType == 'N')
      buf = STR( p1->DoubResult, GetInt( p2 ), GetInt( p3 ));
    else
      buf = STR( p1->StringResult, GetInt( p2 ), GetInt( p3 ));
  }   

  else if( strncmp( Func, "STR", 3 ) == 0 && p2 ) {
    ptype = 's';
    buf = STR( p1->StringResult, GetInt( p2 ));
  }

  else if( strncmp( Func, "STR", 3 ) == 0 && p1 ) {
    ptype = 's';
    buf = STR( p1->StringResult );
  }
   
  else if( strncmp( Func, "SUBSTR", 6 ) == 0 ) {
    ptype = 's';
    buf = SUBSTR( p1->StringResult, GetInt( p2 ), GetInt( p3 )); 
  }
  else if( strncmp( Func, "TRIM", 4 ) == 0 ) {  
    ptype = 's';
    buf = TRIM( p1->StringResult );
  }  
  else if( strncmp( Func, "UPPER", 5 ) == 0 ) {  
    ptype = 's';
    buf = UPPER( p1->StringResult );
  }  
  else if( strncmp( Func, "VAL", 3 ) == 0 ) {  
    ptype = 'd';
    DoubResult = VAL( p1->StringResult );
  }  
  else if( strncmp( Func, "YEAR", 4 ) == 0 ) {  
    ptype = 'd';
    DoubResult = YEAR( p1->StringResult );
  }  
  if( p1 && !p1->InTree ) delete p1;
  if( p2 && !p2->InTree ) delete p2;
  if( p3 && !p3->InTree ) delete p3;
  if( !FuncNode->InTree ) delete FuncNode;
  if( buf ){
    len = strlen( buf );
    WorkNode = new xbExpNode;
    if( !WorkNode )
      return XB_NO_MEMORY;
    WorkNode->ResultLen = len + 1;
    
  } else {    
    len = 0;
    WorkNode = new xbExpNode;
    if( !WorkNode )
      return XB_NO_MEMORY;
    WorkNode->ResultLen = 0;
  }

  switch( ptype ){
   case 's':                               /* string or char result */
    WorkNode->DataLen = len;
    WorkNode->ExpressionType = 'C';
    WorkNode->Type = 's';
    WorkNode->StringResult = buf;
    break;
   case 'd':                               /* numeric result */
    WorkNode->DataLen = 0;
    WorkNode->ExpressionType = 'N';
    WorkNode->Type = 'd';
    WorkNode->DoubResult = DoubResult;
    break;
   case 'l':                               /* logical result */
    WorkNode->DataLen = 0;
    WorkNode->ExpressionType = 'L';
    WorkNode->Type = 'l';
    WorkNode->IntResult = IntResult;
    break;
   default:
    std::cout << "\nInternal error. " << ptype;
    break;
  }
  Push(WorkNode);
  return XB_NO_ERROR;
}