String arrays (Pascal vs. Basic)

{========
Newsgroups: comp.lang.pascal.borland
Subject: String Arrays
From: Jeff <edu...@unb.ca>
Date: Fri, 16 Feb 1996 11:48:32 -0400

I am having troubles converting an old QuickBASIC program of mine to
Turbo Pascal 7.0.   I'm trying to create an Array of 25 strings like:

 var
   Choices: Array[0..25] of String;

Yet I can not figure out how I could use this variable correctly in
the
routine:

 for X:=1 to Length(Choice(Y)) do
   begin
    Write(Choice(Y)[X]);
   end;

I DO KNOW that I screwed up the moment I used () as part of the
variable.  I just couldn't see how I could use the [] to pick a
character
out of the one string of the array.

Any ways I can go about this that will work?  }
-----------------------------------------

I'm not sure what you wanted to do. If you wanted to write all the
strings in the array 'Choices' It would be:
For X := 0 TO 25 DO Writeln(Choices[X]; If you were extracting
characters from one of the strings in the array of strings,
This should do it for you.

<clifp...@airmail.net.    5:13PM  2/16/96

Program StrArray;

VAR
{I'm assuming each string is a maximum of one line on the screen.
 If so you can reduce the memory required per string from 255 to 80.}

Choices: Array[0..25] of String[80];
x, y: Integer;

BEGIN
     {Making sure the empty array of strings is clear, for safety.}
     For x := 0 to 25 do Choices[x] := '';

     Writeln;  Writeln; Writeln;

     y := 15; {arbitrary}

     (* y is 16th (counting 0) string in the array of strings *)

     Choices[y] := 'The quick brown fox jumped over the lazy dogs .';
     Writeln('The whole string Choices[y].');
     Writeln (Choices[y]);
     Writeln;

     (* Choices[y][x] is the x'th char in an array of chars (now
called a
       string) *)

     Writeln('The same string backwards, one character at a time.');
     For x := Length(Choices[y]) downto 1 do Write(Choices[y][x]);
     Writeln;   Writeln;

Writeln('<<Press Enter>>');
Readln;
END.