String arrays (Pascal vs. Basic) 
Author Message
 String arrays (Pascal vs. Basic)

Newsgroups: comp.lang.Pascal.borland
Subject: String Arrays

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:

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

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

 for X:=1 to Length(Choice(Y)) do

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
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.

Program StrArray;

{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;

     {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]);

     (* 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>>');

Wed, 18 Jun 1902 08:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Pascal Records vs BASIC Types

2. String vs. String literal

3. lgarray0.zip TP unit for huge arrays and arrays of sorted strings

4. Pascal Problem...Array[0] in String.

5. Pascal Question about alphabetizing an array of strings...Thanks

6. help with pascal arrays and strings !!!

7. Delphi vs visual basic

8. Delphi vs Visual Basic

9. Delphi/VB/PB vs. Business Basic


11. Visual Basic Vs. Visual C++

12. Visual Basic Vs. Visual C++


Powered by phpBB® Forum Software