HPlogo 900 Series HP 3000 Computer Systems: MPE/iX Intrinsics Reference Manual > Chapter 4 Command Definitions

SEARCH

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

NM and CM callable (differences noted below).

Searches a specially-formatted array for a specified entry or name.

Syntax

      I16            CA    I16V     CA

   entrynum:=SEARCH(buffer,length,dictionary,

                      @*

                   definition);

Functional Return

entrynum

16-bit signed integer (assigned functional return)

Returns the entry number of the name in dictionary that matches buffer. If the name specified in buffer is not found, a zero is returned.

Parameters

buffer

character array (required)

Passes the name for which the search is to be performed.

length

16-bit signed integer by value (required)

Passes the length, in characters, of the array buffer.

dictionary

character array (required)

Passes the name of the specially formatted array that is to be searched for buffer.

definition

(NM) 32-bit address (optional)

(CM) 16-bit address (optional)

Returns the address of the command entry definition in dictionary.

Operation Notes

The SEARCH intrinsic requires a specially formatted array of sequential entries. Each entry in the array is formatted in the following way:

byte 1

An integer that specifies the length (in bytes) of the entire entry. (The length includes this byte.)

byte 2

An integer that specifies the length (in bytes) of the name.

bytes 3 +

A string containing the name. (This name and the name length are checked against the search string for a match.)

bytes x +

An optional string containing a user-defined definition.

The last entry in the array is a zero, specifying the end of the array as an entry of zero length. The following model creates an array to expand abbreviated input (name) to its appropriate command (definition).

   5,1,"I","IN",

   6,1,"O","OUT",

   7,1,"S","SKIP",

   7,1,"E","EXIT",

   0;

In this model, the first entry specifies that the entry's length is five bytes. The name ("I") is one byte and its definition is "IN". A 1 is returned in the entrynum signifying that the matching name was the first entry in the array. (If no matching entry is found, a 0 is returned.) The address of the definition, if specified, is returned in definition of the SEARCH intrinsic call.

Because a search is linear, the most frequently used names should appear at the beginning of the array to ensure efficient searching.

Related Information

Intrinsics

MYCOMMAND

Commands

None

Manuals

None

Feedback to webmaster