• arrays

    From dream master@21:1/163 to All on Wednesday, January 03, 2018 11:54:43
    ok so i have an array of char like this...alphabet : arra
    y[1..26] of char = ('A','B','C','D','E','F','G','H','I','J', 'K','L','M','N','O','P','Q','R','S','T','U','V','W','X'
    ,'Y','Z');i tried this as a const but not luck so i m
    oved to var now it says Message: Cannot init array with val
    ueso i removed the the letters and it worked. is the
    first format not allowed formpl as it is in pascal?
    .úùDream Masterùú
    . øùúùøøùúùø
    DoRE!ACiDiC!Demonic[dream
    land.darktech.org]
    --- Mystic BBS v1.12 A38 2018/01/01 (Windows/64)
    * Origin: |08--[|15!|07dreamland BBS dreamland.darktech.org (21:1/163)
  • From Gryphon@21:1/120 to dream master on Thursday, January 04, 2018 14:20:00
    On 01/03/18, dream master said the following...

    ok so i have an array of char like this...

    alphabet : array[1..26] of char = ('A','B','C','D','E','F','G','H','I','J'
    'K','L','M','N','O','P','Q','R','S','T'
    'U','V','W','X','Y','Z');

    i tried this as a const but not luck so i moved to var now it says
    Message: Cannot init array with vaue

    so i removed the the letters and it worked. is the first format not allowe mpl as it is in pascal?

    No, you can't initialize array values when you declare them. You must set
    the values in a separate statement. I also do not think that arrays can be initialized in that way. You'll have to do:

    alphabet[1]:='A'
    alphabet[2]:='B'
    ...
    alphabet[26]:='Z'

    --- Mystic BBS v1.12 A38 2018/01/01 (Linux/64)
    * Origin: Cyberia BBS | cyberia.darktech.org | San Jose, CA (21:1/120)
  • From tenser@21:1/188 to Gryphon on Thursday, January 04, 2018 20:22:53
    On 01/04/18, Gryphon said the following...

    alphabet[1]:='A'
    alphabet[2]:='B'
    ...
    alphabet[26]:='Z'

    Surely one can use a loop?

    program main;
    var
    alpha: array [1..26] of char;
    i: integer;

    procedure init();
    var
    i: integer;
    begin
    for i := 1 to length(alpha) do
    alpha[i] := chr(i + ord('a') - 1);
    end;

    begin
    init();
    for i := 1 to length(alpha) do
    writeln('alpha[', i, '] = ', alpha[i]);
    end.

    --- Mystic BBS v1.12 A38 2018/01/01 (Raspberry Pi/32)
    * Origin: ACiD Underworld // Victor Ludorum (21:1/188)
  • From g00r00@21:1/108 to Gryphon on Thursday, January 04, 2018 19:56:51
    No, you can't initialize array values when you declare them. You must
    set the values in a separate statement. I also do not think that arrays can be initialized in that way. You'll have to do:

    alphabet[1]:='A'
    alphabet[2]:='B'
    ...
    alphabet[26]:='Z'

    You would declare it as a string because strings are just arrays of
    characters:

    Var
    Alphabet : String[26] = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
    Count : Byte;
    Begin
    For Count := 1 to 26 Do
    WriteLn(Alphabet[Count]);

    End.

    --- Mystic BBS v1.12 A39 2018/01/04 (Windows/32)
    * Origin: Sector 7 [Mystic BBS WHQ] (21:1/108)
  • From Static@21:2/140 to Gryphon on Thursday, January 04, 2018 20:17:30
    On 01/04/18, Gryphon said the following...

    alphabet[26]:='Z'

    Thankfully ASCII alphas are sequential so you could get away with a for loop.

    --- Mystic BBS v1.12 A38 2018/01/01 (Linux/64)
    * Origin: Subcarrier BBS (21:2/140)
  • From dream master@21:1/163 to Gryphon on Thursday, January 04, 2018 18:30:52
    On 01/04/18, Gryphon said the following...
    ok so i have an array of char like this...
    alphabet : array[1..26] of char = ('A','B','C','D','E','F','G','H','I
    'K','L','M','N','O','P','Q','R','S
    'U','V','W','X','Y','Z');
    i tried this as a const but not luck so i moved to var now it says
    Message: Cannot init array with vaue
    so i removed the the letters and it worked. is the first format not a mpl as it is in pascal?
    No, you can't initialize array values when you declare them. You must
    set the values in a separate statement. I also do not think that arrays can be initialized in that way. You'll have to do:
    alphabet[1]:='A'
    alphabet[2]:='B'

    dang more work. i guess mpl in it's format wont support that yet. works in pascal.

    thanks for the input(); =)

    |08 .|05ú|13ù|15Dr|07e|08am Ma|07st|15er|13ù|05ú|08.
    |08 øù|05ú|13ùø |13øù|05ú|08ùø
    |11 DoRE|03!|11ACiDiC|03!|11Demonic |08[|15dreamland|09.|15darktech|09.|15org|08]

    --- Mystic BBS v1.12 A38 2018/01/01 (Windows/64)
    * Origin: |08--[|15!|07dreamland BBS dreamland.darktech.org (21:1/163)
  • From dream master@21:1/163 to g00r00 on Thursday, January 04, 2018 18:40:30
    On 01/04/18, g00r00 said the following...
    No, you can't initialize array values when you declare them. You mus set the values in a separate statement. I also do not think that arr can be initialized in that way. You'll have to do:
    alphabet[1]:='A'
    alphabet[2]:='B'
    You would declare it as a string because strings are just arrays of characters:
    Var
    Alphabet : String[26] = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
    Count : Byte;
    Begin
    For Count := 1 to 26 Do
    WriteLn(Alphabet[Count]);

    End.

    interesting. im trying to write a hangman game in mpl as i work on the pascal version and im going to finish the pascal version first then convert to mpl i started some what on the mpl

    |08 .|05ú|13ù|15Dr|07e|08am Ma|07st|15er|13ù|05ú|08.
    |08 øù|05ú|13ùø |13øù|05ú|08ùø
    |11 DoRE|03!|11ACiDiC|03!|11Demonic |08[|15dreamland|09.|15darktech|09.|15org|08]

    --- Mystic BBS v1.12 A38 2018/01/01 (Windows/64)
    * Origin: |08--[|15!|07dreamland BBS dreamland.darktech.org (21:1/163)