Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Problem whith ARRAY of STRING

valiquettepvaliquettep Posts: 2Member
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

  • zibadianzibadian Posts: 6,349Member
    : 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:
    : [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.
  • Phat NatPhat Nat Posts: 757Member
    : 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:
    :
    [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

  • valiquettepvaliquettep Posts: 2Member

    Phat,

    READLN work well. Tank you very much !

    Patrice

Sign In or Register to comment.