1 registered members (AndrewAMD),
1,310
guests, and 1
spider. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Simplification?
#245261
01/09/09 05:18
01/09/09 05:18
|
Joined: Jul 2008
Posts: 54 Taipei, Taiwan
PlaystationThree
OP
Junior Member
|
OP
Junior Member
Joined: Jul 2008
Posts: 54
Taipei, Taiwan
|
Is there a way simplify this? Thanks in advance
...
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: Quad]
#245264
01/09/09 05:56
01/09/09 05:56
|
Joined: Jul 2008
Posts: 54 Taipei, Taiwan
PlaystationThree
OP
Junior Member
|
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
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
|
TEXT array:
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:
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:
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
testDummy
Serious User
|
Serious User
Joined: Oct 2004
Posts: 1,655
|
// 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_);
}
}
|
|
|
|