2 registered members (AndrewAMD, TipmyPip),
12,420
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: generate a string name
[Re: Damocles]
#113941
02/26/07 13:19
02/26/07 13:19
|
Joined: Dec 2006
Posts: 40
viktoria
OP
Newbie
|
OP
Newbie
Joined: Dec 2006
Posts: 40
|
I want to show the content of Question+i string in my programm. I have many questions and i must select 2 from they. var i will be generated per random 2 times and corresponding questions will be shown. For example: Code:
string Question1 = "Some text 1"; ... string Question10 = "Some another text 10";
var i = int(random (10)); // for example return 5 draw_text("Question" + i,100,10,vector(100,100,255)); var j = int(random (10)); // for example return 10 draw_text("Question" + j,100,10,vector(100,100,255));
// as result i want to see: Some text 5 Some another text 10 My question is how can i call the right string in draw_text or in text{ string=....} block?
|
|
|
Re: generate a string name
[Re: Damocles]
#113943
02/26/07 22:37
02/26/07 22:37
|
Joined: Mar 2006
Posts: 2,503 SC, United States
xXxGuitar511
Expert
|
Expert
Joined: Mar 2006
Posts: 2,503
SC, United States
|
Here's another idea... Code:
string the_question; string tStr; function select_question(number) { str_for_num(tStr, number); str_cpy(the_question, "str_cpy(tStr, question_"); str_cat(the_question, tStr); str_cat(the_question, ");"); execute(the_question); str_cpy(the_question, tStr); }
This will work with any number of strings, without using a ton of "if" statements.
Last edited by xXxGuitar511; 02/27/07 15:21.
xXxGuitar511 - Programmer
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|