Results 1 to 5 of 5

Thread: String array inside string array?

  1. #1
    Join Date
    May 2018
    Posts
    17
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default String array inside string array?

    How do i place a string array inside an string array.

    Logically i thought it would be something like this:

    Code:
    procedure array();
    var
      array_1:array[1..1] of string;
      array_2:array[1..1] of string;  
    
    begin
    
      array_1[1] := 'test'
    
      array_2[1] := 'test', array_1[1] ,'test';
     
    end
    That doesn't seem to be working. Any idea what i'm doing wrong? There's probably a simple solution.

  2. #2
    Join Date
    Oct 2012
    Posts
    1,258
    Mentioned
    40 Post(s)
    Quoted
    588 Post(s)

    Default

    Only strings can go into a string array.

    Simba Code:
    procedure arrays();
    var
      MyStr: string;
      array_1: array[0..1] of string;
      array_2: array[0..1] of array of string;
    begin
      MyStr := 'test';
      writeln(MyStr);

      array_1[0] := MyStr;
      array_1[1] := MyStr;
      writeln(array_1);

      array_2[0] := array_1;
      array_2[1] := array_1;
      writeln(array_2);
    end;

    If you're using either of the SRLs, you'll have a tstringarray.simba file in the include. You can learn from and use the functions there.

  3. #3
    Join Date
    Aug 2018
    Posts
    17
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

    Default

    Quote Originally Posted by matthew98 View Post
    How do i place a string array inside an string array.

    Logically i thought it would be something like this:

    Code:
    procedure array();
    var
      array_1:array[1..1] of string;
      array_2:array[1..1] of string;  
    
    begin
    
      array_1[1] := 'test'
    
      array_2[1] := 'test', array_1[1] ,'test';
     
    end
    That doesn't seem to be working. Any idea what i'm doing wrong? There's probably a simple solution.
    I'm on my phone so can't really help test but I found a link (can't post due to post count) but you can search Pascal multi-dimensional Arrays. Might be what you are looking for?

  4. #4
    Join Date
    May 2018
    Posts
    17
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by Hastega View Post
    I'm on my phone so can't really help test but I found a link (can't post due to post count) but you can search Pascal multi-dimensional Arrays. Might be what you are looking for?
    Thank you Hastega, i will check that out.

  5. #5
    Join Date
    Feb 2009
    Location
    Irvine, CA
    Posts
    2,873
    Mentioned
    8 Post(s)
    Quoted
    138 Post(s)

    Default

    Use a 2d string array (array of array of strings) and you can just have the entries where you need one string to be a length 1 array. like so:
    Simba Code:
    arrayofarrayofstring := [['just a string'],
     ['or even', 'a couple'],
     ['or maybe', 'use', '3'],
     ['or back to just one']];

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •