QMExecute()

Top  Previous  Next

 

The QMExecute() function executes a command on the server.

 

 

Format

 

VBQMExecute(ByVal Cmnd as String, ByRef Errno as Integer) as String

 

Cchar * QMExecute(char * Cmnd, int * Errno)

 

ObjStr = Session->Execute(Cmnd, Errno)

 

where

 

Cmndis the command to be executed.

 

Errnois an integer variable to receive status information.

 

 

The QMExecute() function executes the specified command on the server. The output from this command is returned as a text string. If the command does not produce any output, the C API returns a null pointer.

 

If the command completes without requesting input, the Errno variable is set to SV_OK.

 

If the command requests input, any output up to that point is returned and the Errno variable is set to SV_PROMPT. The client may respond to this using the QMRespond() function or abort the command using the QMEndCommand() function.

 

On completion of the command, QMStatus() will return the value of @SYSTEM.RETURN.CODE.

 

The executed command may perform most functions of the QM database. Specific restrictions are:

Input may be requested from the client using the QMBasic INPUT and INPUT@ statements. Use of the KEYIN() function is not allowed.

Testing for input using the QMBasic KEYREADY() function or the INPUT -1 syntax will not show input waiting.

The length parameter of an INPUT statement will be ignored if present.

Execution of a further command from within the executed command may not behave correctly.

 

Examples

 

VB

S = QMExecute("RUN MYPROG", ErrNo)

while ErrNo = SV_PROMPT

  ...Process returned value and get new Response...

  S = QMRespond(Response, ErrNo)

wend

...Process final response...

C

S = QMExecute("RUN MYPROG", &ErrNo)l

while(ErrNo == SV_PROMPT)

{

 ...Process returned value and get new Response...

 QMFree(S);

 S = QMRespond(Response, &ErrNo);

}

...Process final response...

QMBasic

S = session->QMExecute("RUN MYPROG", ErrNo)

LOOP

WHILE ErrNo = SV$PROMPT

  ...Process returned value and get new Response...

REPEAT

...Process final response...

 

The above program fragment runs a program named MYPROG on the server. This program repeatedly outputs data using CRT, DISPLAY or PRINT and prompts for user input. Each output /response pair is handled by the client loop until the program terminates.

 

 

See also:

QMEndCommand, QMRespond()