prgmwitch 0 Newbie Poster

I need to write a program where the user enters a paragraph, the program reads in, stores every fifth word in a separate bank (array), and outputs the paragraph with the fifth words removed and replaced with 15 spaces. As usual, I finished the code, edited repeatedly, and can't find my error.... Help?!!!

TYPE
   INPUTS = ARRAY[1..45] OF STRING;
   FIFTHWORDS = ARRAY[1..45] OF STRING;

VAR
   CHECK5 : REAL;
   FIFTHWORD : FIFTHWORDS; {ARRAY OF MISSING WORDS}
   STRLEN : INTEGER; {READS LENGTH OF STRING W/O MISSING WORDS}
   FIFTEENSPACE : STRING; {FILLER}
   WORDCOUNT : INTEGER;
   NUM5WORDS : INTEGER; {AMOUNT OF 5TH WORDS}
   ALS : INTEGER; {START OF FIFTH WORDS}
   C : INTEGER; {CHAR POSITION T/O ALL PARAGRAPH}
   STARTCHAR : INTEGER; {BEGINNING OF STRING TO BE ADDED TO PARAGRAPH}
   STRING2 : STRING; {STRING ADDED TO NEW PARAGRAPH W/O 5TH WORDS}

   USERINPUT : INPUTS; {STRING OF ORIGINAL USER INPUTS}
   PARAGRAPH : STRING; {CONCATED STRING OF ORIGINAL USER INPUTS}
   PARAGRAPH2 : STRING; {FINAL PARAGRAPH}
   COUNT : INTEGER; {COUNTER FOR USERINPUT}
   N, I, L : INTEGER;
   LAST : INTEGER;   {COUNTER FOR SEARCHING WHOLE PARAGRAPH}
   CHECKIT : STRING; {CHAR COPYING PIECE BY PIECE OF PARAGRAPH}
   CHAR1 : CHAR;  {CHAR COPY OF CHECKIT}
   SPACE : STRING; {POSITION OF SPACE}


BEGIN {WORD AND PARAGRAPH COUNT PRGRM}
WRITELN ('PLEASE ENTER YOUR PARAGRAPH.');
COUNT := 1;
WORDCOUNT := 0;
C :=0;
CHECK5 := 1;
ALS := 0;
FIFTEENSPACE := '               ';
STARTCHAR := 0;
STRING2 := '';
STRLEN := 0;
STRING2 := '';
LAST := 0;
NUM5WORDS := 1;
PARAGRAPH2 := '';
PARAGRAPH := '';

WHILE NOT EOLN DO
BEGIN {READ PARAGRAPH}
      READLN (USERINPUT[COUNT]);
      COUNT := COUNT + 1;
END; {READ PARAGRAPH}

PARAGRAPH := CONCAT(USERINPUT[1], USERINPUT[2], USERINPUT[3], USERINPUT[4], USERINPUT[5], USERINPUT[6]);
PARAGRAPH := CONCAT(PARAGRAPH, USERINPUT[7], USERINPUT[8], USERINPUT[9], USERINPUT[10], USERINPUT[11], USERINPUT[12]);
PARAGRAPH := CONCAT(PARAGRAPH, USERINPUT[13], USERINPUT[14], USERINPUT[15], USERINPUT[16], USERINPUT[17], USERINPUT[18]);
PARAGRAPH := CONCAT(PARAGRAPH, USERINPUT[19], USERINPUT[20], USERINPUT[21], USERINPUT[22], USERINPUT[23], USERINPUT[24]);
PARAGRAPH := CONCAT(PARAGRAPH, USERINPUT[25], USERINPUT[26], USERINPUT[27], USERINPUT[28], USERINPUT[29], USERINPUT[30]);
PARAGRAPH := CONCAT(PARAGRAPH, USERINPUT[31], USERINPUT[32], USERINPUT[33], USERINPUT[34], USERINPUT[35]);

LAST := LENGTH(PARAGRAPH);
NUM5WORDS := 1;
I := 0;
WHILE I <= LAST DO
BEGIN {FOR LETTER IN WORDCOUNT STATEMENT}
      CHECKIT := COPY(PARAGRAPH, I, 1);
      CHAR1 := CHECKIT[1];
      C := ORD(CHAR1);
      IF (CHECKIT <> CHAR(32)) THEN
        BEGIN {FIRST IF}
        END; {FIRST IF}

      IF (CHECKIT = CHAR(32)) THEN
            BEGIN
                WORDCOUNT := WORDCOUNT + 1;
                CHECK5 := WORDCOUNT MOD 5;
                IF CHECK5 = 0 THEN
                BEGIN {FIFTH WORDS}
                      N := C - ALS;
                      FIFTHWORD[NUM5WORDS] := COPY (PARAGRAPH, ALS, N);
                      NUM5WORDS := NUM5WORDS + 1;
                      STRLEN := ALS-1;
                      STRLEN := STRLEN - STARTCHAR;
                      STRING2 := COPY(PARAGRAPH, STARTCHAR, STRLEN);
                      PARAGRAPH2 := CONCAT (PARAGRAPH2, STRING2, FIFTEENSPACE);
                      STARTCHAR := 15 - N;
                      STARTCHAR := STARTCHAR + C;
                END; {FIFTH WORDS}

                ALS := POS (SPACE, CHECKIT);
                ALS := ALS + 1;
           END;
I := I + 1;
END; {FOR LETTER IN WORDCOUNT STATEMENT}
WRITELN (PARAGRAPH2);
END. {WORD AND PARAGRAPH COUNT PRGRM}

Thanks!!!!!

PS- I also ATTACHED a txt version for better viewing if desired...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.