0

Hey guys
I am trying to prompt the user to input a file name, and save that file name into a packed array of characters
then use that inputed flename to perform some opertions.

FileName : text;
Line = PACKED ARRAY [0..79] of char ;
writeln('Please input a file name to read input from.');
readln(FileName);
ASSIGN(InputFile,FileName); 
RESET(InputFile);

The ASSIGN statement throws the following error: Error: Can't determine which overloaded function to call
Can anyone help me resolve this issue?
Thanks

Edited by alex910TN: no

2
Contributors
10
Replies
13
Views
4 Years
Discussion Span
Last Post by alex910TN
0

No it is not.
What additional code is required that may help?
Thanks

0

Here is most of my code for the main program.
I have also included the various function definition headers.
Thanks

 PROGRAM WordCount (input, output, InputFile,OutputFile);
            CONST
               WordSize = 15;    (* Maximum size of words allowed. *)
            Type
               Line = PACKED ARRAY [0..79] of char ;
               str = PACKED ARRAY [0..WordSize-1] of char;

               (* Pointers to Node and List objects *)
               NodePointer = ^Node;
               ListPointer = ^List;

               Node = Record        (* Structure to define a Node *)
                        FrequencyCount : integer;
                        WordSize       : integer;
                        Word           : str;
                        Next           : NodePointer
                      END;
               List = Record    (* Structure needed to define an array of pointers *)
                        NodeCount: integer;
                        head     : NodePointer
                      END;
                (* ARRAY OF 26 POINTERS *)
                ReferenceArray = Array [0..25] of List;
            VAR
               i,SizeOfArray,count         : integer;
               InputFile,OutputFile : text;   (* FILE VARIABLES*)
               PointerArray : ReferenceArray;
               RawInput,FormattedInput,ValidWords: Line; (* ARRAY OF CHAR'S TO HOLD LINE CONTENTS *)
               CandidateNodeList : ListPointer;
               FileName :Line;

        BEGIN  (* START MAIN PROCEDURE *)
              writeln('Please input a file name to read input from. File must be located in source file directory.');
              readln(FileName);
              writeln('FileName = ', FileName);
              readln;

              ASSIGN(InputFile,(FileName));
              reset(InputFile);
              ASSIGN(OutputFile,'IndexOut.txt');
              rewrite(OutputFile);

              count :=0;
              writeln(OutPutFile,'**********************************************************************');
              writeln(OutputFile,'               FILE CONTENTS');
              writeln(OutPutFile,'**********************************************************************');
              (* Initialize PointerArray Proper Begining values*)
              while( count < WordSize) do
                 BEGIN
                    PointerArray[count].head := NIL;
                    PointerArray[count].NodeCount := 0;
                    count := count + 1;
                 END; (*END WHILE LOOP*)

              While not eof(InputFile) do
                BEGIN
                    i := 0;
                    SizeOfArray := 0;
                   while not eoln(InputFile) do (*Processes line contents *)
                      BEGIN  (* BEGIN WHILE LOOP *)
                         read( InputFile, RawInput[i]);
                         i := i + 1;
                         SizeOfArray := SizeOfArray + 1;
                      END; (*END WHILE LOOP *)

                   writeln(OutputFile,RawInput);
                   FormattedInput := UpperCase(RawInput, SizeOfArray); (* FormattedInput Will Contain All Uppercase characters*)

                   ValidWords := IsolateWords(FormattedInput, SizeOfArray);(* All Valid words will be sperated by a '/' symbol*)
                   CandidateNodeList := CreateNodes (ValidWords);         (*Nodes to insert into array of pointers*)

                   Insert(CandidateNodeList, PointerArray);
                   readln(InputFile); (* GO TO NEXT LINE *)

                   for i:= 0 to 79 do  (*CLEAR ARRAY BEFORE NEXT LINE IS READ IN*)
                      RawInput[i] := ' ';

                END;(* END OF While not eof(InputFile) *)
              writeln(OutPutFile,'**********************************************************************');
              writeln(OutputFile,'                            Index: ');
              writeln(OutPutFile,'**********************************************************************');
              Print(PointerArray);
              writeln(OutPutFile,'**********************************************************************');
              close(InputFile);
              close(OutputFile);
              writeln('Press any key to exit...');
              readln
        END.  (* END MAIN PROCEDURE *)

FUNCTION & PROCEDURE DEFINITIONS:

FUNCTION UpperCase (lineContents : Line; ArraySize : integer) :Line;
FUNCTION IsolateWords ( UpperCaseWords:Line; ArraySize:integer):Line;
FUNCTION CreateNodes ( ValidWords : Line) : ListPointer;
FUNCTION Compare ( Node1 : NodePointer; Node2 :NodePointer): integer;
PROCEDURE Insert (ProspectWords : ListPointer; VAR IndexArray : ReferenceArray);
PROCEDURE Print ( WordList: ReferenceArray);

These functions and procedures all work as intended I already double checked. However, I just cant seem to understand why it is giving me that error msg in the ASSIGN fuction in main procedure.

0

Yes I have but I am not going to lie to you, this is part of an assignment and the assignment guidelines state that I can only use aspects that where included in orginal Pascal. Orginal Pascal did not include the string type.
Thanks

0

I think I has something to do with the parameters in the main procedure.

PROGRAM WordCount (input, output, InputFile,OutputFile);

The way I understand this is the input and output refer to the console I/O, whereas
InputFile and OutputFile refer to programmer defined variables of type text.
I don't know. This is crazy.
Thanks for any future assistance.
Alex.

0

Okay. Just looked at the Pascal standards book by Wirth and there is no mention of Assign. Although the error points to it, I cannot confirm the issue.

Edited by pritaeas

0

Thats true but there exceptions to those guidelines. Sorry for troubling you.
But I changed the way I am doing this.
here are the changes I have made.

writeln('Please input a file name to read input from. File must be located in source file directory.');
    count:=0;
    while not eoln (input) do
       BEGIN
          read(input, FileName[count]);
          count := count + 1
       END; (*END FOR LOOP *)

       (*Padding with blanks*)
       while (count < 20) do
       BEGIN
           FileName[count] := ' ';
           count := count + 1;
       END;

However, this still did not solve my problem.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.