Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: stuh505 on Tue 11/05/2004 23:29:47

Title: Arrays of strings
Post by: stuh505 on Tue 11/05/2004 23:29:47
ok...i tried the string class method and the generic method,

string skills[5] = {"dddsf", "fgfdg", fdfg", "fgdf", "fgdfs"};

and

char skills[5][10] = {"dddsf", "fgfdg", fdfg", "fgdf", "fgdfs"};

and variations of each.

i looked in the help file, the online manual, and browsed some of the other tutorial/information files.

i'm sure it's out there but i'm wasting too much time on this, please throw me a bone.

Edit by strazer:

AGS v2.71's new "String" type supports this:

  String skills[5];
  skills[0] = "dddsf";
  skills[1] = "fgfdg";
  skills[2] = "fdfg";
  skills[3] = "fgdf";
  skills[4] = "fgdfs";

Tracker entry: http://www.adventuregamestudio.co.uk/tracker.php?action=detail&id=111
Title: Re: arrrrgggh: array of strings?
Post by: Scorpiorus on Tue 11/05/2004 23:36:37
Generally you can't have array of strings in AGS...generally.

An official workaround would be to make use of SetGlobalString()/GetGlobalString() functions.



The unofficial one is:

// main global script

// ***must always be 200***
#define AGS_STRING_LENGTH 200

struct STRING {
   char line[AGS_STRING_LENGTH];
};


So, from now you can have:

STRING array[10];


StrCopy(array[3].line, "blah blah");



And the last one:
You can set up a GUI and put a listbox onto it. Thus, it gives you about 150 strings you can manipulate with ListBox* family functions.
Title: Re: arrrrgggh: array of strings?
Post by: stuh505 on Tue 11/05/2004 23:56:53
wow....i am astonished that such a common feature would be such a pain.

what is a "line" ? never heard of that before

anyway, the whole reason I wanted this function was so that I could fill up a list box!  so...are you saying that I have to do "add item" command for EACH item i want to populate the list box?
Title: Re: arrrrgggh: array of strings?
Post by: TerranRich on Wed 12/05/2004 01:24:36
This is a good question, but better suited for the Tech Archives now that it has been answered. It will be moved. :)
Title: Re: arrrrgggh: array of strings?
Post by: Scorpiorus on Wed 12/05/2004 07:52:28
Quote from: stuh505 on Tue 11/05/2004 23:56:53what is a "line" ? never heard of that before
Ah, line is just a name, I forgot to add its type, but it has to be a char one. I've corrected my above post.

Quoteanyway, the whole reason I wanted this function was so that I could fill up a list box!Ã,  so...are you saying that I have to do "add item" command for EACH item i want to populate the list box?
Well, yes, currently it is the only way out with them, since there is no a function such as ListBoxSetItemText at the moment.


Quote from: terranRICH on Wed 12/05/2004 01:24:36
This is a good question, but better suited for the Tech Archives now that it has been answered. It will be moved. :)
Sure Rich, thanks for moving it. ;)
Title: Re: Having an array of strings
Post by: Pumaman on Wed 12/05/2004 21:43:24
Yeah, arrays aren't officially supported at all - and the lack of support for arrays of strings is the main reason. It's a technical issue due to the way that strings are implemented internally, but as it's not a feature that most people require, it's not a priority to add.