Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: wynni2 on Thu 22/03/2018 16:26:42

Title: redefining sizes of dynamic arrays
Post by: wynni2 on Thu 22/03/2018 16:26:42
UPDATE - my apologies, after posting I reread the manual entry again, and it answered my question.

PLEASE DISREGARD. 

Hi all -

I've been looking at the manual and forums, but I can't find an answer to this question that makes sense at my (very basic) level. 

I'm writing a function that would generate a list containing multiple items (strings). 

Can I declare a dynamic array and then declare a new size for that array each time the function is called? 

This is what I'm thinking of:
Code (ags) Select

String rstring[];

String MakeList(int howmanyitems) {
    rstring = new String[howmanyitems];
    String output = "";
    char i; 
    while (i<howmanyitems) {
        rstring[i] = ##SELECT FROM A PREEXISTING ARRAY#;
        output = output.Append(rstring[i]);
        i++;
    }
    return output;
}


I'd like to know if this is going to compile, or if I'm misusing dynamic arrays.

Thanks