finishing some functions in this code

Posted by osabri on Stack Overflow See other posts from Stack Overflow or by osabri
Published on 2010-04-27T00:37:48Z Indexed on 2010/04/27 0:43 UTC
Read the original article Hit count: 337

Filed under:

i have problem to finish some functions in this code

program lab4;

var inFile : text;
var pArray : array[1..10]of real;   //array of 10 integer values containing patterns to search in a given set of numbers
var rArray : array[1..10]of integer;    //array containing result of pattern search, each index in rArray coresponds to number of occurences of 
                        //pattern from pArray in sArray.
var sArray : array[1..100] of real;     //array containing data read from file
var     accuracy : real;

(****************************************************************************)
function errMsg:integer;

begin
    if ParamCount < 3 then
        begin
         writeln('Too few arguments');
         writeln('Usage: ./lab4 lab4.txt <accuracy> <pattern_1> <pattern_2> <pattern_n>');
         errMsg:=-1;
        end
    else if ParamCount > 12 then
        begin 
         writeln('Too many arguments');
         writeln('Maximum number of patterns is 10');
         errMsg:=-1;
        end
    else
        begin   
         assign(inFile,ParamStr(1));
         {$I-}
         reset(inFile);
         if ioresult<>0 then
          begin 
           writeln('Cannot open ',ParamStr(1));
           errMsg:=-1;
          end
         else   
          errMsg:=0;
        end;
end;
(****************************************************************************)
procedure readPattern;
    var errPos,idx:integer; 
begin
    if errMsg=0 then
        begin
            for idx:=1 to ParamCount-2 do
             begin
                Val(ParamStr(idx+2),pArray[idx],errPos);        
                writeln('pArray:',pArray[idx]:2:2);
             end;
        end;

end;


(****************************************************************************)
procedure getAccuracy; //Function should get the accuracy as the first param (after the program name)
begin
    (here where i stopped : (( )
end;
(****************************************************************************)
function readSet:integer; //Function returns number of elements read from file
    var idx,errPos:integer;
    var     sChar: string;
begin
    if errMsg=0 then
        begin
            idx:=1;
            repeat
                begin
                    readln(inFile,sChar);
                    VAL(sChar,sArray[idx],errPos);
                    writeln('sArray:',sArray[idx]:2:2);
                    idx:=idx+1;
                end
            until eof(inFile)=TRUE;
        end;
    readSet:=idx-1;
end;
(****************************************************************************)
procedure searchPattern(sNumber:integer); //Function should search and count pattern(patterns) occurence in a given set 

what the best solution for this part??
(****************************************************************************)
procedure dispResult; //Function should display the result of pattern(patterns) search
begin

(****************************************************************************)
begin
    readPattern;
    getAccuracy;
    searchPattern(readSet);
    dispResult;

end.

© Stack Overflow or respective owner

Related posts about pascal