function RT_PP_SPEC = PP_FEVAL(PR_OPTIONS,PR_PATH,PR_COMMAND,varargin)
%RT_PP_SPEC = PP_FEVAL(PR_OPTIONS,PR_PATH,PR_COMMAND,varargin)
%
% This function places a request in PR_PATH for a
% PP server process to evaluate PR_COMMAND with parameters
% given by the varargin. A PP specification is returned
% which can be used to check the status of the request via
% PP_CHECK and to retrieve the results via PP_RETRIEVE.
% PP server processes must be manually started via the
% command PP_SERVER. Behavior of this function can be
% customized via the parameter PR_OPTIONS which is a text
% string of the form "opt1=val1&opt2=val2;...." The options
% allowed are:
%
% PAUSE - When equal to a positive value,
% the function will return only after processing of
% the request has begun by one of the servers and this
% routine will check every PR_PAUSE seconds. Otherwise,
% this routine will return immediately.
% PREFIX - A text string to be used as a prefix for all
% communication files between this process and the server
% processes. The default is 'PP_REQ'.
% This file and the DistributePP software package were created and
% are maintained by Michael D. DeVore. The package originated in
% November, 1999. Permission is granted by the author for anyone
% to use or modify this software provided that:
% (1) any modified files are documented internally to clearly indicate
% that they have been modified from the original release; and
% (2) it is recognized that neigher Michael D. DeVore nor Washington
% University assumes any liability for the use or misuse of the software.
% Default option values...
LV_PAUSE = 0;
LV_PREFIX = 'PP_REQ';
% Extract options...
LV_OPTION_TAIL = PR_OPTIONS;
while length(LV_OPTION_TAIL) > 0
[LV_OPT,LV_OPTION_TAIL] = strtok(LV_OPTION_TAIL,'=');
LV_OPT = deblank(strrep(LV_OPT,'&',''));
[LV_VAL,LV_OPTION_TAIL] = strtok(LV_OPTION_TAIL,'&');
LV_VAL = strrep(LV_VAL,'=','');
if strcmp('PAUSE',upper(LV_OPT)) == 1
LV_PAUSE = str2double(LV_VAL);
end
if strcmp('PREFIX',upper(LV_OPT)) == 1
LV_PREFIX = LV_VAL;
end
end
% Generate a unique name for this request...
LV_SUFFIX = num2str(PP_SEQUENCE([PR_PATH LV_PREFIX '.seq']));
RT_PP_SPEC = [PR_PATH LV_PREFIX '_' LV_SUFFIX];
% Save all information necessary to satisfy the request...
LV_PROC_SPEC.Arguments = varargin;
LV_PROC_SPEC.Command = PR_COMMAND;
LV_PROC_SPEC.Options = PR_OPTIONS;
LV_PROC_SPEC.WorkingDir = pwd;
LV_PROC_SPEC.Path = '';
LV_LOC_PATH = path;
LV_DEF_PATH = pathdef;
while (length(LV_LOC_PATH)>1)
[LV_TOK,LV_LOC_PATH] = strtok(LV_LOC_PATH,':');
if (isempty(findstr(LV_DEF_PATH,LV_TOK)))
LV_PROC_SPEC.Path = [LV_PROC_SPEC.Path LV_TOK ':'];
end
end
save(RT_PP_SPEC,'LV_PROC_SPEC');
% Create the file indicating a request for service...
fclose(fopen([RT_PP_SPEC '.req'],'w'));
% If requested, wait until the file indicating the request has been picked up...
if LV_PAUSE > 0
LV_FP = fopen([RT_PP_SPEC '.prc'],'r');;
while LV_FP < 0
pause(LV_PAUSE)
LV_FP = fopen([RT_PP_SPEC '.prc'],'r');
end
fclose(LV_FP);
end