Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Quad), 608 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
string arrays #425391
07/03/13 23:22
07/03/13 23:22
Joined: Nov 2008
Posts: 354
saeculum II
MPQ Offline OP
Senior Member
MPQ  Offline OP
Senior Member

Joined: Nov 2008
Posts: 354
saeculum II
hi,

is it possible to initialize string arrays such as:

STRING *myString[2] = { "a", "b"};

this example throws an error message, but is there any way I can get this workin?


new project in early stage...

Intel Xeon X3450 2,66GHz | Mushkin 8 Gib | Zotac GTS250 + 7300LE | A8.3 com
Re: string arrays [Re: MPQ] #425392
07/03/13 23:23
07/03/13 23:23

M
Malice
Unregistered
Malice
Unregistered
M



Use the string array build into the TEXT* object.. Look up TEXT in engine objects in the manual.

Take a look at how it was used here http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=424023#Post424041

It also sound right to make a array of pointers and fill it later.

Code:
STRING* array_strings[1000];

function this_func()
{ var x;
   for(x=0;x<1000;x++)
      { 
         array_strings[x] = str_create(" Some Text");

       }
}




Last edited by Malice; 07/04/13 04:14.
Re: string arrays [Re: ] #425451
07/05/13 11:36
07/05/13 11:36
Joined: Nov 2008
Posts: 354
saeculum II
MPQ Offline OP
Senior Member
MPQ  Offline OP
Senior Member

Joined: Nov 2008
Posts: 354
saeculum II
thank you, but the I have the problem that

my_text->string = array_strings[0]

doesnt work!


Last edited by MPQ; 07/05/13 11:36.

new project in early stage...

Intel Xeon X3450 2,66GHz | Mushkin 8 Gib | Zotac GTS250 + 7300LE | A8.3 com
Re: string arrays [Re: MPQ] #425452
07/05/13 11:40
07/05/13 11:40
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
you left off a 'p'

str_cpy((my_text.pstring)[7], "Test!"); // lite-C


Free world editor for 3D Gamestudio: MapBuilder Editor
Re: string arrays [Re: sivan] #425487
07/06/13 11:37
07/06/13 11:37
Joined: Nov 2008
Posts: 354
saeculum II
MPQ Offline OP
Senior Member
MPQ  Offline OP
Senior Member

Joined: Nov 2008
Posts: 354
saeculum II
wow thanks thats workin fine.

hopefully my last question:
I wanna use a text array as well, such as

TEXT* my_text[2]

str_cpy((my_text[0]->pstring)[7], my_str[0]);

but I get an error message!


new project in early stage...

Intel Xeon X3450 2,66GHz | Mushkin 8 Gib | Zotac GTS250 + 7300LE | A8.3 com
Re: string arrays [Re: MPQ] #425488
07/06/13 11:40
07/06/13 11:40
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
when using TEXT like this you have to allocate memory manually (afaik) or use something like text_create (if such thing exists) because you don't really create a text object but an array of pointers.


POTATO-MAN saves the day! - Random
Re: string arrays [Re: Kartoffel] #425489
07/06/13 12:06
07/06/13 12:06
Joined: Nov 2008
Posts: 354
saeculum II
MPQ Offline OP
Senior Member
MPQ  Offline OP
Senior Member

Joined: Nov 2008
Posts: 354
saeculum II
hmm ye I see I am tryin to figure sth out


new project in early stage...

Intel Xeon X3450 2,66GHz | Mushkin 8 Gib | Zotac GTS250 + 7300LE | A8.3 com
Re: string arrays [Re: MPQ] #425493
07/06/13 14:02
07/06/13 14:02
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Originally Posted By: MPQ
TEXT* my_text[2]

str_cpy((my_text[0]->pstring)[7], my_str[0]);

You have no idea what you're doing, have you?

This is wrong syntax as well as nonsense. Read about operator precendece. Don't try to create an array of texts. The text object already has an array of strings. When using text objects you have to create them with http://www.conitec.net/beta/atxt_create.htm.


Always learn from history, to be sure you make the same mistakes again...
Re: string arrays [Re: MPQ] #425495
07/06/13 14:55
07/06/13 14:55
Joined: Sep 2009
Posts: 993
Budapest
Aku_Aku Offline
User
Aku_Aku  Offline
User

Joined: Sep 2009
Posts: 993
Budapest
Before you copy a string into a string, you have to initialize the target (if this usage of the string will be the first).
Like this:
Code:
TEXT* txt_TxtContent[16];
...
	for(inx=0; inx <16; inx++) {
		txt_TxtContent[inx] = txt_create(1,0);
	}


Last edited by Aku_Aku; 07/06/13 14:56.
Re: string arrays [Re: Aku_Aku] #426142
07/17/13 07:10
07/17/13 07:10
Joined: Oct 2002
Posts: 2,256
Oz
L
Locoweed Offline
Expert
Locoweed  Offline
Expert
L

Joined: Oct 2002
Posts: 2,256
Oz
TEXT* txtGoals =
{
strings = 16;
}

TEXT* txtGoalsList =
{
string ("Whatever","Blah Blah","Oh Yeah baby!");
}

str_cpy((txtGoals.pstring)[0],"Whatever");
str_cpy((txtGoals.pstring)[1],"Blah Blah");

or

(txtGoals.pstring)[0] = (txtGoalsList.pstring)[0]; // "Whatever"

(txtGoals.pstring)[1] = (txtGoalsList.pstring)[1]; // "Blah Blah"

You know, whatever,
Later,
Loco


Professional A8.30
Spoils of War - East Coast Games

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1