Example #1
0
File: find.c Project: ryuever/sgrid
/** Search for objects that match criteria
	\p start may be a previous search result, or \p FT_NEW.
	\p FT_NEW starts a new search (starting with all objects)

	Searches criteria may be as follows:

		find_objects(\p FT_NEW, \p ftype, \p compare, \p value[, ...], \p NULL);

	and may be grouped using \p AND and \p OR.

	The criteria list must be terminated by \p NULL or \p FT_END.

	Values of \p ftype are:
		- \p FT_ID		 compares object ids (expects \e long value)
		- \p FT_SIZE	 compares object size excluding header (expects \e long value)
		- \p FT_CLASS	 compares object class name (expects \e char* value)
		- \p FT_PARENT	 uses parent for comparison (must be followed by another \p ftype)
		- \p FT_RANK	 compares object rank by number (expects \e long value)
		- \p FT_CLOCK	 compares object clock (expects \e TIMESTAMP value)
		- \p FT_PROPERTY compares property (expects \e char* value)
		- \p FT_MODULE	 compares module name
		- \p FT_ISA		 compares object class name including parent classes (expected \e char* value)

	Extended values of \p ftype are:
		- \p CF_NAME	looks for a particular name
		- \p CF_LATT	compares object lattitudes
		- \p CF_LONG	compares object longitudes
		- \p CF_INSVC	checks in-service timestamp
		- \p CF_OUTSVC	checks out-service timestamp

	Values of \p compare are:
		- \p EQ			equal
		- \p NE			not equal
		- \p LT			less than
		- \p GT			greater than
		- \p LE			less than or equal
		- \p GE			greather than or equal
		- \p NOT		opposite of test
		- \p BETWEEN	in between
		- \p SAME		same string
		- \p BEFORE	    alphabetic before
		- \p AFTER		alphabetic after
		- \p DIFF		alphabetic differ
		- \p MATCH		matches \e regex
		- \p LIKE		matches \e regex
		- \p UNLIKE		matches "not" \e regex

	Conjunctions are \e AND and \e OR, and can be used to do complex searches

	OBJECT *find_first(FINDLIST *list) returns the first object in the result list

	OBJECT *find_next(FINDLIST *list, OBJECT *previous) returns the next object in the result list

	@return a pointer for FINDLIST structure used by find_first(), find_next, and find_makearray(), will return NULL if an error occurs.
**/
FINDLIST *find_objects(FINDLIST *start, ...)
{	
	int ival;
	char *sval;
	OBJECTNUM oval;
	TIMESTAMP tval;
	double rval;
	OBJECT *obj;
	FINDLIST *result = start;
	if (start==FL_NEW || start==FL_GROUP)
	{
		result=new_list(object_get_count());
		ADDALL(*result);
	}
	/* FL_GROUP is something of an interrupt option that constructs a program by parsing string input. */
	if (start==FL_GROUP)
	{
		FINDPGM *pgm;
		va_list(ptr);
		va_start(ptr,start);
		pgm = find_mkpgm(va_arg(ptr,char*));
		if (pgm!=NULL){
			return find_runpgm(result,pgm);
		} else {
			va_end(ptr);
			DELALL(*result); /* pgm == NULL */
			return result;
		}
	}
Example #2
0
//---------------------------------------------------------------------------
void __fastcall TMainForm::Addalltosecondtable1Click(TObject *Sender){ADDALL();}