示例#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( 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
示例#3
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