Arrays of strings

Started by stuh505, Tue 11/05/2004 23:29:47

Previous topic - Next topic

stuh505

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

Scorpiorus

#1
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.

stuh505

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?

TerranRich

This is a good question, but better suited for the Tech Archives now that it has been answered. It will be moved. :)
Status: Trying to come up with some ideas...

Scorpiorus

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. ;)

Pumaman

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.

SMF spam blocked by CleanTalk