Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, dr_panther), 1,282 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Simplification? #245261
01/09/09 05:18
01/09/09 05:18
Joined: Jul 2008
Posts: 54
Taipei, Taiwan
PlaystationThree Offline OP
Junior Member
PlaystationThree  Offline OP
Junior Member

Joined: Jul 2008
Posts: 54
Taipei, Taiwan
Is there a way simplify this? Thanks in advance smile

Code:
  ...
   str_cpy((text1.pstring)[0],"value1");
   str_cpy((text2.pstring)[0],"value2");
   str_cpy((text3.pstring)[0],"value3");
   str_cpy((text4.pstring)[0],"value4");
   str_cpy((text5.pstring)[0],"value5");
   str_cpy((text6.pstring)[0],"value6");
   str_cpy((text7.pstring)[0],"value7");
   str_cpy((text8.pstring)[0],"value8");
   str_cpy((text9.pstring)[0],"value9");
   str_cpy((text10.pstring)[0],"value10");
    ...
 


This actually goes on up to 100 TEXT* structs, which is the reason for simplification.


Bet you don't know where Taiwan is lol.

"The Lord is my light and my salvation..." Psm 27:1
Re: Simplification? [Re: PlaystationThree] #245262
01/09/09 05:20
01/09/09 05:20
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
you may try using a text array? and you may try texts with more than 1 lines?


3333333333
Re: Simplification? [Re: Quad] #245264
01/09/09 05:56
01/09/09 05:56
Joined: Jul 2008
Posts: 54
Taipei, Taiwan
PlaystationThree Offline OP
Junior Member
PlaystationThree  Offline OP
Junior Member

Joined: Jul 2008
Posts: 54
Taipei, Taiwan
A text array? Could you elaborate, I've not heard of it before. The text with multiple lines is a good idea though. Thanks you very much.


Bet you don't know where Taiwan is lol.

"The Lord is my light and my salvation..." Psm 27:1
Re: Simplification? [Re: PlaystationThree] #245282
01/09/09 08:17
01/09/09 08:17
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
TEXT array:

Code:
TEXT* txt_array[40];


int main(){
	
	
	int i =0;
	for(i=0;i<40;i++){
		txt_array[i]=txt_create(1,1);
		txt_array[i].pos_y = 10*i;
		set(txt_array[i],SHOW);
		str_cpy((txt_array[i].pstring)[0],"initial text");
	}

}


multi-line text ver1:
Code:
TEXT* txt ={
	strings = 40;//40 lines
	flags = SHOW;//  VISIBLE changed as SHOW in 7.66
}

int main(){
	int i =0;
	for(i=0;i<40;i++){
		str_cpy((txt.pstring)[i],"initial text");
	}
}


ver 2:
Code:
TEXT* txt ={
	strings = 1;//1 strings
	flags = SHOW;//  VISIBLE changed as SHOW in 7.66
}

int main(){
	int i =0;
	str_cpy((txt.pstring)[0],"initial text\n");
	for(i=0;i<39;i++){
		str_cat((txt.pstring)[0],"initial text\n");
	}
}



3333333333
Re: Simplification? [Re: Quad] #245323
01/09/09 13:33
01/09/09 13:33
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655
Code:
// not equivalent to above & may be irrelevant
// untested - but similar should work
// temps
var i = 0;
STRING* s1_ = "#128";

// dumps var array into strings of TEXT object
// _t TEXT object
// _na  var array  (i.e. var1[32])
// _nLen length of var array or number of elements to dump (i.e. 32)
void varf_toText(TEXT* _t, var* _na, var _nLen) {
	if (_t == NULL) { return; }
	i = 0;
	for (i = 0; i<_t.strings && i<_nLen; i++);
		str_for_num(s1_, _na[i]);
		str_cpy((text1.pstring)[i], s1_);
	}
}



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