Gamestudio Links
Zorro Links
Newest Posts
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, VoroneTZ, 1 invisible), 1,512 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
concatenating strings and arrays #172627
12/13/07 05:51
12/13/07 05:51
Joined: Jun 2007
Posts: 28
D
Doriel Offline OP
Newbie
Doriel  Offline OP
Newbie
D

Joined: Jun 2007
Posts: 28
Hello,

I have a small problem that I hope someone has seen before. In my game, I am trying to track a user's actions towards a patient along with the game time of each action. The user can view his/her last 15 actions at any time for any given patient.

Now, since there are multiple patients, I decided to use a multi-dimensional (faked) array to store the actions. I have a nice little panel that shows up and displays the list of actions. Everything works fine, except the game time.

For the game time, I have a string variable game_time that is updated every iteration. So when it's time to track a message, I simply do something like the following:


p_actions_taken[currentPatient * p_num_of_actions[currentPatient]] = "my action message here";
p_num_of_actions[currentPatient] = p_num_of_actions[currentPatient] + 1;
p_time_of_action[currentPatient * p_num_of_actions[currentPatient]] = game_time;


When I try concatenating the game_time into it, it always shows the current game_time, not the time when the array was updated.

I am assuming the array only holds a pointer to the game_time string instead of a copy of the actual string. Is there any way around this? I was hoping there was a way to concatenate strings without using str_cat. I believe if I was able to do something as follows, it would work:

p_actions_taken[currentPatient * p_num_of_actions[currentPatient]] = game_time + " " + "my action message here";

But that only gives an error.

Any ideas?

Regards,

Doriel

Re: concatenating strings and arrays [Re: Doriel] #172628
12/15/07 01:54
12/15/07 01:54
Joined: Jun 2007
Posts: 28
D
Doriel Offline OP
Newbie
Doriel  Offline OP
Newbie
D

Joined: Jun 2007
Posts: 28
did i not explain this enough? or is there really no fix for this?

Re: concatenating strings and arrays [Re: Doriel] #172629
12/15/07 08:05
12/15/07 08:05
Joined: Jul 2006
Posts: 503
Australia
A
adoado Offline

User
adoado  Offline

User
A

Joined: Jul 2006
Posts: 503
Australia
Quote:


I am assuming the array only holds a pointer to the game_time string instead of a copy of the actual string





Arrays I think only hold numbers (vars) and not strings directly, so it would be a pointer to a string that it would be holding.

Maybe try

p_time_of_action[currentPatient * p_num_of_actions[currentPatient]] = str_create(game_time);

I am not fully understanding the problem (thats my fault - I am a little sleepy ) - so I am not sure whether this is the right answer or not

Somehow copy the contents of "game_time" into a new string and then use the new string so the array value is no longer pointing to game_time...

Thanks,
Adoado


Visit our development blog: http://yellloh.com
Re: concatenating strings and arrays [Re: adoado] #172630
12/15/07 12:04
12/15/07 12:04
Joined: Aug 2000
Posts: 1,140
Baunatal, Germany
Tobias Offline

Moderator
Tobias  Offline

Moderator

Joined: Aug 2000
Posts: 1,140
Baunatal, Germany
For concatenating strings there's the str_cat function. "+" is an addition operator and used to add two numbers. It has nothing to do with strings.

Re: concatenating strings and arrays [Re: Tobias] #172631
12/15/07 15:51
12/15/07 15:51
Joined: Jun 2007
Posts: 28
D
Doriel Offline OP
Newbie
Doriel  Offline OP
Newbie
D

Joined: Jun 2007
Posts: 28
adoado,

str_create() is exactly what i needed. works as advertised. thanks so much!

- doriel


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