Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (7th_zorro, AndrewAMD), 911 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Changing Strings at runtime #290812
09/21/09 15:26
09/21/09 15:26
Joined: Apr 2009
Posts: 138
Germany
T
Toryno Offline OP
Member
Toryno  Offline OP
Member
T

Joined: Apr 2009
Posts: 138
Germany
How can I change the string of digits or of a TEXT* ? (at runtime)


Thanks for reading, thinking, answering wink
Re: Changing Strings at runtime [Re: Toryno] #290813
09/21/09 15:30
09/21/09 15:30
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
You can use the pstring array together with str_cpy...

str_cpy((my_text.pstring)[7], "Hello"); // Set 8th string to "Hello"

The 7 in the [] is the index of the string to edit, in this case it would edit the 8th string (indexes start with 0).

Last edited by DJBMASTER; 09/21/09 15:30.
Re: Changing Strings at runtime [Re: DJBMASTER] #290815
09/21/09 15:33
09/21/09 15:33
Joined: Dec 2008
Posts: 271
Saturnus Offline
Member
Saturnus  Offline
Member

Joined: Dec 2008
Posts: 271
And you can use pan_setdigits() to modify digits.

Re: Changing Strings at runtime [Re: Saturnus] #290818
09/21/09 15:57
09/21/09 15:57
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
if you have only one String (no Array) you can use str_cpy

Re: Changing Strings at runtime [Re: Widi] #290826
09/21/09 17:00
09/21/09 17:00
Joined: Apr 2009
Posts: 138
Germany
T
Toryno Offline OP
Member
Toryno  Offline OP
Member
T

Joined: Apr 2009
Posts: 138
Germany
Hmm, can you say me what this code makes?


STRING* my_string = "hello";
...
my_string = "bye"; // I mean this line


Thanks for reading, thinking, answering wink
Re: Changing Strings at runtime [Re: Toryno] #290827
09/21/09 17:01
09/21/09 17:01
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
str_cpy(my_string,"bye");


3333333333
Re: Changing Strings at runtime [Re: Quad] #290829
09/21/09 17:20
09/21/09 17:20
Joined: Apr 2009
Posts: 138
Germany
T
Toryno Offline OP
Member
Toryno  Offline OP
Member
T

Joined: Apr 2009
Posts: 138
Germany
Aha, so that's the same =D

But it still don't want to work correctly, when the function chose_target is called, you can't see the digits no more. Why?

Code:
PANEL* targets =
{
	layer = 5;
	button = 0,0, cg_released_pcx, cg_normal_pcx, cg_over_pcx,chose_target,NULL,NULL;
	digits = 2,2, "target: first", "Arial#24", 0, 0;
}

void chose_target() {
	pan_setdigits(targets,1,2,2, "target: last", "Arial#24", 0, 0);
}




Thanks for reading, thinking, answering wink
Re: Changing Strings at runtime [Re: Toryno] #290865
09/21/09 23:23
09/21/09 23:23
Joined: Aug 2003
Posts: 63
UK
ptrc1c Offline
Junior Member
ptrc1c  Offline
Junior Member

Joined: Aug 2003
Posts: 63
UK
Hi Toryno,
I have found a way to do this

////////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>

////////////////////////////////////////////////////////////////////

STRING* temp_text ="pete";

var* tee;
tee = 3;
function main()
{
video_mode = 7;
screen_color.blue = 150;
mouse_mode = 4;
}



//////////////////////////////////////////////////////////////////////

PANEL* main_pan =
{
bmap = "main.pcx";
pos_x = 250;
pos_y = 200;
button (250, 134, "quitclicked.pcx", "quitnormal.pcx", "quitover.pcx", quit_program, NULL, NULL);
digits (200,100, "%s",*,1,temp_text);
flags = OVERLAY | VISIBLE;
}

function quit_program()
{

str_cpy(temp_text,"Its changed");

}

Re: Changing Strings at runtime [Re: ptrc1c] #290885
09/22/09 06:19
09/22/09 06:19
Joined: Apr 2009
Posts: 138
Germany
T
Toryno Offline OP
Member
Toryno  Offline OP
Member
T

Joined: Apr 2009
Posts: 138
Germany
Yes, thats good! Thank you laugh


Thanks for reading, thinking, answering wink

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