コード例 #1
0
void CloseSomeDatapath( PSENTIENT ps, PTEXT parameters, PDATAPATH *root )
{
	int datasource;
	PTEXT temp = GetParam( ps, &parameters );
	if( temp )
	{
		PDATAPATH pdp = FindOpenDevice( ps, temp );
		if( pdp )
			DestroyDataPath( pdp );
	}
	else
	{
		datasource = 1;
		do
		{
			if( root )
			{
				if( (*root) )
				{
					datasource = (*root)->flags.Data_Source;
					DestroyDataPath( (*root) );
				}
				else
					datasource = 1;
			}
		} while( !datasource );
	}
}
コード例 #2
0
//--------------------------------------
int CPROC PARSE( PSENTIENT ps, PTEXT parameters )
{
	PTEXT temp;
	PTEXT devname;
	if( ( devname = GetParam( ps, &parameters ) ) )
	{
	// find device to see if it's already open...
	// by name!
	// but - this causes a problem for nested scripts
	// which are going to have to be artificiailly inceminated
	// with a unique name maybe something like script_#####
		PDATAPATH pdp = FindOpenDevice( ps, devname );
		if( pdp )
		{
			if( !ps->CurrentMacro )
			{
				PVARTEXT pvt;
				pvt = VarTextCreate();
				vtprintf( pvt, WIDE("Device named %s is already open."), GetText( devname ) );
				EnqueLink( &ps->Command->Output, (POINTER)VarTextGet( pvt ) );
				VarTextDestroy( &pvt );
			}
			return -1;
		}
		if( ( temp = GetParam( ps, &parameters ) ) )
		{
			PDATAPATH pdp;
			lprintf( WIDE("Opening device handle named: %s"), GetText( devname ) );
			if( ( pdp = OpenDevice( &ps->Data, ps, temp, parameters ) ) )
			{
				while( devname->flags & TF_INDIRECT )
					devname = GetIndirect( devname );
				pdp->pName = SegDuplicate( devname );
				if( pdp->Type )
				{
					if( ps->CurrentMacro )
					{
						ps->CurrentMacro->state.flags.bSuccess = TRUE;
					}
				}
				else
				{
					DestroyDataPath( pdp ); // new one did not finish open...
				}
			}
		}
		else
		{
			DECLTEXT( msg, WIDE("Parse must specify a name (/(parse/open) <name> <device> <options...)") );
			EnqueLink( &ps->Command->Output, (PTEXT)&msg );
		}
	}
	return FALSE;
}
コード例 #3
0
   else
		move( r->top-1, column );

}
//----------------------------------------------------------------------------


__declspec(dllimport) int IsConsole;
DECLTEXT( ConsoleName, "wincon" );

//----------------------------------------------------------------------------

static PTEXT DeviceVolatileVariableGet( "console", "rows", "console row count" )(PENTITY pe,PTEXT *ppLastValue)
{
	PSENTIENT ps = pe->pControlledBy;
	PDATAPATH pdp = FindOpenDevice( ps, (PTEXT)&ConsoleName );
   return GetRows( (uintptr_t)pdp, pe, ppLastValue );
}
static PTEXT DeviceVolatileVariableGet( "console", "cols", "console col count" )(PENTITY pe,PTEXT *ppLastValue)
{
	PSENTIENT ps = pe->pControlledBy;
	PDATAPATH pdp = FindOpenDevice( ps, (PTEXT)&ConsoleName );
   return GetCols( (uintptr_t)pdp, pe, ppLastValue );
}
static PTEXT DeviceVolatileVariableGet( "console", "cursor_x", "console cursor x(col) position" )(PENTITY pe,PTEXT *ppLastValue)
{
	PSENTIENT ps = pe->pControlledBy;
	PDATAPATH pdp = FindOpenDevice( ps, (PTEXT)&ConsoleName );
   return GetCursorX( (uintptr_t)pdp, pe, ppLastValue );
}
static PTEXT DeviceVolatileVariableGet( "console", "cursor_y", "console cursor y(row) position" )(PENTITY pe,PTEXT*ppLastValue)
コード例 #4
0
//--------------------------------------
int CPROC COMMAND( PSENTIENT ps, PTEXT parameters )
{
	PTEXT temp;
	 PTEXT devname;
	 if( ( devname = GetParam( ps, &parameters ) ) )
	 {
		  // find device to see if it's already open...
		  // by name! 
		  // but - this causes a problem for nested scripts
		  // which are going to have to be artificiailly inceminated
		  // with a unique name maybe something like script_#####
		  PDATAPATH pdp = FindOpenDevice( ps, devname );
		  if( pdp )
		  {
			if( !ps->CurrentMacro )
			{
					 PVARTEXT pvt;
					 pvt = VarTextCreate();
					 vtprintf( pvt, WIDE("Device named %s is already open."), GetText( devname ) );
					 EnqueLink( &ps->Command->Output, (POINTER)VarTextGet( pvt ) );
					 VarTextDestroy( &pvt );
				}
				return -1;
		  }
		 if( ( temp = GetParam( ps, &parameters ) ) )
		  {
			  PDATAPATH pdp;

			  //lprintf( WIDE("Opening device handle named: %s"), GetText( devname ) );
			  if( ( pdp = OpenDevice( &ps->Command, ps, temp, parameters ) ) )
			  {
				  PTEXT pCommand;
				  PDATAPATH pOldPath;
				  while( devname->flags & TF_INDIRECT )
					  devname = GetIndirect( devname );
				  pdp->pName = SegDuplicate( devname );
				  if( ps->Command )
				  {
				  // remove old command queue so close won't remove
				  // ps->Command->Input = NULL;
				  // close the command queue...

				  // update to the new queue in the sentience
				  // if the new one is a data source, then we
				  // need to move old commands to new path -
				  // otherwise they may/will get lost.
					  if( ps->Command->flags.Data_Source
						 && !ps->Command->flags.Dont_Relay_Prior)
								 {
									 pOldPath = ps->Command->pPrior;

												 // move all commands from old queue to new queue
									 while( ( pCommand = (PTEXT)DequeLink( &pOldPath->Input ) ) )
									 {
										 EnqueLink( &ps->Command->Input, pCommand );
									 }

									 while( ( pCommand = (PTEXT)DequeLink( &pOldPath->Output ) ) )
									 {
										 EnqueLink( &ps->Command->Output, pCommand );
									 }
								 }
				  }
				  if( ps->CurrentMacro )
					  ps->CurrentMacro->state.flags.bSuccess = TRUE;
			  }
		  }
		  else
		  {
				DECLTEXT( msg, WIDE("Command must specify a name (/command <name> <device> <options...)") );
				EnqueLink( &ps->Command->Output, (PTEXT)&msg );
		  }
	}
	return FALSE;
}