Пример #1
0
MFUNC(modulefact, MCnop)
{
  // one argument expected
  MFnargsCheck(1);

  if(MFisInt(MFarg(1))) {
    long value = MFlong(MFarg(1));
    if (value > 0) 
      MFreturn(MFlong(fact(value)));
  } 

  MFreturn(MFcopy(MVargs));
} MFEND
Пример #2
0
} MFEND

///////////////////////////////////////////////////////////////////////////////
MFUNC ( kernelPath, MCnop )
{ MFnargsCheck( 0 );
  MFreturn( MFstring(MUPV_env.progName) );
} MFEND
Пример #3
0
} MFEND


///////////////////////////////////////////////////////////////////////////////
MFUNC ( kernelPid, MCnop )
{ MFnargsCheck( 0 );
  MFreturn( MFlong(MFprocId()) );
} MFEND
Пример #4
0
} MFEND


///////////////////////////////////////////////////////////////////////////////
MFUNC ( userName, MCnop )
{ MFnargsCheck( 0 );

  char *user = MFprocUserName();  
  if( user == NULL ) 
      MFerror( "Not supported for this operating system" );

  MFreturn( MFstring(user) );
} MFEND
Пример #5
0
} MFEND


///////////////////////////////////////////////////////////////////////////////
MFUNC( date, MCnop )
{ MFnargsCheck( 0 );

  time_t clock;
  time( &clock );

  char *string = ctime(&clock);
  string[24] = '\0';

  MFreturn( MFstring(string) );
} MFEND
Пример #6
0
} MFEND


///////////////////////////////////////////////////////////////////////////////
MFUNC( busyWaiting, MCnop )
{ MFnargsCheck( 1 );
  MFargCheck  ( 1, DOM_INT );

    unsigned long sec = (unsigned long) MFlong( MFarg(1) );
    if( sec < 0L || sec > 60*60*24L ) 
        MFerror( "Integer is out of range 0..86400" );

    unsigned long   t1, t2;
    // 64Bit Windows: sizeof(int)<>sizeof(size_t)
    for( t1 = t2 = static_cast<unsigned long>(time(NULL)); (t2-t1) < sec; 
	 t2 = static_cast<unsigned long>(time(NULL)) ) ;
    MFreturn( MFcopy(MVnull) );
} MFEND
Пример #7
0
} MFEND


///////////////////////////////////////////////////////////////////////////////
MFUNC( sleep, MCnop )
{ MFnargsCheck( 1 );
  MFargCheck  ( 1, DOM_INT );

  unsigned long sec = (unsigned long) MFlong( MFarg(1) );
  if( sec < 0L || sec > 60*60*24UL )   
      MFerror( "Integer is out of range 0..86400" );

#if   (defined MACINTOSH)
    MFerror( "Sorry, not supported on this platform" );
#elif (defined WIN32)
    Sleep( sec*1000UL );
#else
    sleep( sec );
#endif

    MFreturn( MFcopy(MVnull) );
} MFEND