Hi, I'm new to pascal. I use free pascal compiler ver. 1.0.10. on Widows XP Pro.
I'm trying to make an array of string. I have a problem when I write a string in the array. At the second loop, stop to the instruction Read.
Thank you for any help.
Patrice
Here's my code:
PROGRAM Test;
CONST iMax = 7;
TYPE MyArray = ARRAY[1..iMax] OF STRING;
VAR TestTab : MyArray;
ind :INTEGER;
BEGIN
FOR ind := 1 TO 5 DO
BEGIN
WRITE ('Entrez une chaine de caractere >');
READ (TestTab[ind])
END;
END.
Comments
:
: I'm trying to make an array of string. I have a problem when I write a string in the array. At the second loop, stop to the instruction Read.
: Thank you for any help.
:
: Patrice
:
: Here's my code:
: [code]
: PROGRAM Test;
:
: CONST iMax = 7;
:
:
: TYPE MyArray = ARRAY[1..iMax] OF STRING;
:
:
: VAR TestTab : MyArray;
: ind :INTEGER;
:
: BEGIN
:
[red]:
: FOR ind := 1 TO 5 DO
: BEGIN
: WRITE ('Entrez une chaine de caractere >');
: READ (TestTab[ind])
: END;
: [/red]
: END.
: [/code]
:
:
Which second loop? There is only 1 loop (indicated in red). And also what do you mean by stop? If you want to stop executing the program at that point for debugging purposes, set a breakpoint. If you want to see the effects of the program, you need to run it inside a console window.
:
: I'm trying to make an array of string. I have a problem when I write a string in the array. At the second loop, stop to the instruction Read.
: Thank you for any help.
:
: Patrice
:
: Here's my code:
:
[code]
: PROGRAM Test;
:
: CONST iMax = 7;
:
:
: TYPE MyArray = ARRAY[1..iMax] OF STRING;
:
:
: VAR TestTab : MyArray;
: ind :INTEGER;
:
: BEGIN
:
:
: FOR ind := 1 TO 5 DO
: BEGIN
: WRITE ('Entrez une chaine de caractere >');
:[b] READ (TestTab[ind])[/b]
: END;
:
: END.
[/code]
I think that should be a [b]ReadLn()[/b], not a [b]Read()[/b]. See if that helps.
Phat Nat
Phat,
READLN work well. Tank you very much !
Patrice