Get MBLogic at SourceForge.net. Fast, secure and Free Open Source 
	software downloads

Help Topics

Topic Details for Soft Logic

Search Instructions


Search instructions are used to search a range of registers to find a value which matches the search criteria. The search value may be a register, constant, or string constant.

Continuous Search

Instruction Description # Params One Shot Symbol
FINDEQ Search table for equal to 5 or 6 X search
FINDGE Search table for >= 5 or 6 X search
FINDGT Search table for > 5 or 6 X search
FINDLE Search table for <= 5 or 6 X search
FINDLT Search table for < 5 or 6 X search
FINDNE Search table for not equal 5 or 6 X search

Incremental Search

Instruction Description # Params One Shot Symbol
FINDIEQ Incremental search table for equal to 5 or 6 X search
FINDIGE Incremental search table for >= 5 or 6 X search
FINDIGT Incremental search table for > 5 or 6 X search
FINDILE Incremental search table for <= 5 or 6 X search
FINDILT Incremental search table for < 5 or 6 X search
FINDINE Incremental search table for not equal 5 or 6 X search
FINDNE Search table for not equal 5 or 6 X search

Search instructions each come in two forms - continuous and incremental. A continuous search will begin at the start of the search register range each time it is invoked. An incremental search will begin at the next position after the last match. If the last incremental search did not result in a match before it reached the end of the range, the next search will start at the beginning again.

The search instructions expect the following parameters:

FINDEQ searchvalue start end result resultflag (one-shot)

The result of a search is placed in the specified register. If the search was successful (a match was found), the register is set to an integer value equal to the index (number of elements) from the beginning of the search range to where the match was found. If the search was not successful, the result register is set to -1.

When a string constant is used as the search value, the search is conducted by comparing the entire string to a number of registers equal to the length of the string. If a match is not found, the search position increments by one register position and repeats until a match is found or the end of the search range is reached.

Example:


	// Search for constant.
	NETWORK 1
	STR X1
	FINDEQ 1 DS100 DS110 DS111 C111
	
	// Search for register.
	NETWORK 2
	STR X2
	FINDGT DD112 DD100 DD110 DS112 C112
	
	// Search for character.
	NETWORK 3
	STR X3
	FINDEQ "c" TXT100 TXT110 DS113 C113
	
	// Search for character string.
	NETWORK 3
	STR X3
	FINDEQ "cde" TXT100 TXT110 DS114 C114
	
	// Search with one shot.
	NETWORK 5
	STR X5
	FINDIEQ 15 DS100 DS110 DS115 C115 1


Ladder Examples

The following shows examples in ladder format.

search example 1 search example 2