Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AndrewAMD, Baklazhan, Ayumi, Hanky27), 1,387 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
copy an element of an array to a string #390040
12/21/11 19:09
12/21/11 19:09
Joined: Dec 2009
Posts: 256
USA , NY
msmith2468 Offline OP
Member
msmith2468  Offline OP
Member

Joined: Dec 2009
Posts: 256
USA , NY
i have an array. i want the contents of the array to contain a string to be displayed on the screen. i have tried two ways without luck.
The first way i made the array elements contain the contents of the string. aparently i can not do this with an array. so this led me to my second method.
My second method i defined the strings as pointers then filled the array with the pointers. but when i call the value in the array i do not get the string.


Second method.......
in this example Display should be " R E D "
___________________________________________________________
STRING* Title_0 = " Y e l l o w ";
STRING* Title_1 = " R E D ";
STRING* Title_2 = " P U R P L E ";
STRING* Title_3 = " B L U E ";

function fillin()
array[0] = Title_0;
array[1] = Title_1;
array[2] = Title_2;
array[3] = Title_3;

function DisplayStr()
current = 1;
str_cpy (Display,array[current]);
__________________________________________________________

Any help would be appreciated.


Mikes Wicked Games

www.mikeswickedgames.com
Re: copy an element of an array to a string [Re: msmith2468] #390061
12/21/11 23:41
12/21/11 23:41
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Normally, you create string arrays as follows:

STRING* str_array[10];
...
for(i = 0; i < 10; i++) str_array[i] = str_create("");

In your case the "array" would need to be a string array, too, how did you declare it?


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: copy an element of an array to a string [Re: Superku] #390063
12/22/11 00:36
12/22/11 00:36
Joined: Dec 2009
Posts: 256
USA , NY
msmith2468 Offline OP
Member
msmith2468  Offline OP
Member

Joined: Dec 2009
Posts: 256
USA , NY
That was my problem, i had array as a var. when i switch it to a string array then it worked great.

thanks a lot. i have been messing around with this for hours. i would have thought some sort of error would have popped up.

that's what i get for using python for the last 6 months where types are interchangeable.


Mikes Wicked Games

www.mikeswickedgames.com

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

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