Query Section of .Idq Files

The query section of the .idq file specifies parameters that will be used in the query. It can refer to form variables and can include conditional expressions to set a variable to alternative values depending upon some condition.

This topic contains

Sample Query Section

Begin by writing a [Query] tag, and then add a set of parameters. This example assumes that you have done the following:

Here is a simple .idq file:

[Query]
CiScope=/
CiColumns=FileName
CiRestriction=#filename *
CiTemplate=/Scripts/Template.htx

The preceding four parameters are required. In many cases, one or more parameters will be passed down from a form. Here is a very simple form:

<FORM ACTION="/scripts/simple.idq" METHOD="GET">
Query : <INPUT TYPE="TEXT" NAME="Restriction" SIZE="60" MAXLENGTH="100" VALUE="">
<INPUT TYPE="SUBMIT" VALUE="Execute Query">
</FORM>

This form can work with the following .idq file to pass parameters from the user:

[Query]
CiScope=/
CiColumns=FileName
CiRestriction=%Restriction%
CiTemplate=/Scripts/Template.htx

In addition to the four required parameters, there are many optional parameters you can add, such as CiSort and CiForceUseCi. For details, see the full list of parameters in Variables in Forms and in .idq Files.

Conditional Expressions

You can add if-then-else conditional logic to control the substitution of variables and parameters. The syntax is similar to conditional expressions in .htx files, but not exactly the same.

Syntax

The following rules apply to conditional expressions in .idq files:

The following example shows how to set the CiRestriction variable:

CiRestriction=%if Restriction ISEMPTY%Index Server Help%else%%Restriction%%endif%

This example stops users from running empty searches.

The following list shows the possible operators in IF statements for .idq files:

EQ
if value1 equals value2

NE
if value1 does not equal value2

LT
if value1 is less than value2

LE
if value1 is less than or equal to value2

GT
if value1 is greater than value2

GE
if value1 is greater than or equal to value2

CONTAINS
if any part of value1 contains the string value2

ISEMPTY
TRUE if value1 is a Null string. This is a unary postfix operator.

Security Considerations

Be careful when substituting parameters for the CiTemplate parameter because you could unintentionally allow files in scripts directories with only Execute permission to be sent over the network. For example, if an .idq file contained the line

CiTemplate=%CiTemplate%

a client could send a Uniform Resource Locator (URL) that contained the following line in the query string:

CiTemplate=/scripts/mysecretfile.pl

With this string, an unauthorized user could read the contents of a confidential file.

It is better to switch among different .htx files by just using the base name of the file and adding the script directory and file name extension in the parameter substitution. The following file, Sample.idq, shows how to do this:

[Query]
CiRestriction=%q%
CiTemplate=/scripts/%t%.htx
CiSort=%s%
CiScope=/

The query can be executed with a URL like the following:

http://computername/scripts/sample.idq?q=ActiveX&t=form1

Note   A URL or a form-based query can send up to 4 kilobytes (K) of data. If a query larger than 4K is sent, the behavior is unpredictable. The query size includes all variables sent from the browser to the .idq file.


© 1997 by Microsoft Corporation. All rights reserved.