Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
5 registered members (Dico, AndrewAMD, TipmyPip, NewbieZorro, Grant), 15,791 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
append a string with a variable #126090
04/24/07 16:23
04/24/07 16:23
Joined: Dec 2003
Posts: 61
miami
gunplay Offline OP
Junior Member
gunplay  Offline OP
Junior Member

Joined: Dec 2003
Posts: 61
miami
Code:
STRING bed1 = <double.mdl>;
STRING bed2 = <queen.mdl>;
STRING bed3 = <king.mdl>;

var bedNum = 1;


FUNCTION creation(buttonVar,panelVar){
IF (buttonVar == 1 ){ ent_create( "bed + bedNum" ,0,furn_action); }

}



basically i want to take the string bed and add what ever value the variable bedNum is equal too. so i'd end up with bed1. what is the correct syntax for this?


any help would be appreciated

Last edited by gunplay; 04/24/07 16:23.
Re: append a string with a variable [Re: gunplay] #126091
04/24/07 17:48
04/24/07 17:48
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck

Re: append a string with a variable [Re: Xarthor] #126092
04/24/07 18:28
04/24/07 18:28
Joined: Dec 2003
Posts: 61
miami
gunplay Offline OP
Junior Member
gunplay  Offline OP
Junior Member

Joined: Dec 2003
Posts: 61
miami
thnx for the reply, i took a look at these b4 posting but they really dont provied the effect im looking for. for example in melScript (maya scripting language) if i wanted to add on to a string i would type Code:
string $pointAttach = "bob"
string $endAttach = "Model"

select ($pointAttach+$endAttach+"1");



the result would be any object named bobModel1 would be selected.

i just wanted to know if this kind of string flexability is available in c-script and if so what syntax it would have to be in

Re: append a string with a variable [Re: gunplay] #126093
04/24/07 18:39
04/24/07 18:39
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Thoses are the three commands you need for the effect you want.
C-Script does not provide the ability to simply "add" strings.
Plus you have to make sure that everything has the data type "string".
A number's data type is "var", so you have to translate it first:
Code:

string result_str;
string temp_str;

function select(_string1,_string2,_nr)
{
str_for_num(temp_str,_nr);
str_cpy(result_str,_string1);
str_cat(result_str,_string2);
str_cat(result_str,temp_str);
}

//How to call, example:
select("Hello"," World ","2007");

result_str = "Hello World 2007";



Re: append a string with a variable [Re: Xarthor] #126094
04/25/07 01:41
04/25/07 01:41
Joined: Dec 2003
Posts: 61
miami
gunplay Offline OP
Junior Member
gunplay  Offline OP
Junior Member

Joined: Dec 2003
Posts: 61
miami
thank you very much this worked perfectly


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

Gamestudio download | 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