String Array

Posted By: Ralph

String Array - 10/04/08 17:06

Hi,
i would like to use string array´s, but i cant find something about it in the manual.
Anyone know how to use string array´s? (i know that in C++ you can use char array´s)
...Okay i can use delimiter´s in a normal string like this "word%foobar%blubb" and cut the string if i need one of these words, but this is not the best and easiest way. frown

Ralph
Posted By: Vadim647

Re: String Array - 10/05/08 05:14

use TEXT* pointers. You can use them as string arrays, and just keep it not visible. It's fully described in manual.
Posted By: Ralph

Re: String Array - 10/05/08 09:50

I have this idea yesterday, but i dont want to make 100 or more TEXT* pointers.
But thank you.

Ralph
Posted By: Vadim647

Re: String Array - 10/05/08 10:59

You dont understand. TEXT pointer can store in it any cound of strings. Then you just need to use string\pstring to edit or view them.
Posted By: Ralph

Re: String Array - 10/05/08 13:26

Yeah i know that TEXT* Pointers can store hundrets auf Index´s with Strings, but i need much String Array´s and not only 10 or less.

Ralph
Posted By: adoado

Re: String Array - 10/07/08 05:56

You can alternatively use an array of handles to dynamically created strings, eg:

Code:
var MyArrayOfStr[10];

..
//To place a string
MyArrayOfStr[0] = handle(str_create("A new string here"));

..

//To get a string
String* StrPointer;

StrPointer = ptr_for_handle(MyArrayOfStr[0]);


Also remember to use ptr_remove when they are no longer needed wink

The code is not tested, but it should look something like that wink

Thanks,
Adoado
Posted By: TechMuc

Re: String Array - 10/07/08 08:34

I'm pretty sure you can ignore the handles..

MyArrayOfStr[0] = str_create("A new string");
Posted By: Ralph

Re: String Array - 10/07/08 21:36

Thank you guys, this work fine for me!
But what about saving this string array in a external *.txt file?
How can i do this?
Ralph
Posted By: adoado

Re: String Array - 10/07/08 23:50

Just iterate through the array with a while loop, recalling each string and then save it..

There is no direct way to dump the array into a file and get it to keep the strings, as they are not actually string objects but handles.
© 2024 lite-C Forums