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
3 registered members (TipmyPip, AndrewAMD, NewbieZorro), 15,207 guests, and 7 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
Page 2 of 3 1 2 3
Re: listing strings in rows/Liste aus Strings [Re: FBL] #132590
06/01/07 21:45
06/01/07 21:45
Joined: May 2007
Posts: 19
Z
Zalon Offline OP
Newbie
Zalon  Offline OP
Newbie
Z

Joined: May 2007
Posts: 19
I just played around with these lines of code. Actually there weren't any bugs, I just had to add a "*" to the STRING(*) mySTR.

I modified the code in several ways, but don't understand the outcome in all cases. So I'd appreciate your advice again.

As this might become quit complicated, I numbered the different alternatives:

1) First of all, I changed the str_cpy to "str_cpy(mySTR, testCharStruct.charArray[2]);" and expected mySTR to become "s". But that did not happen, mySTR became "st". Obviously all chars beginning with number 2 to the last one were copied in mySTR. But why?

2) After that, I tried to figure out wether a change of the struct will result in only a single value (the "s"). So I changed the code to:

Code:

struct test {
char charArray;
};
struct test testCharStruct[5];
...
testCharStruct[0].charArray='t';
...
str_cpy(MyStr, testCharStruct[2].charArray);



But again the result was "st". Again, why? How do I copy just one value out of the struct?

3) In the next step, I wanted to implement a string into the struct:

Code:

STRING* stringTest;

struct test{
STRING* stringTest[5];
};
...



Here, "str_cpy(MyStr, testStruct.stringTest); indeed only gives one value back, the "t". Obviously strings won't be "summed up". But why are there differences between char arrays and string arrays in structs, when both are - in a way - the same??

4) According to these results, a str_cpy(myStr, testStruct.stringTest[2]); should finally lead to the single "s". But nah.. this line leads to a crash of SED.

5) By changing the struct to an "struct array" like in (2) SED crashed immediately.


And now, I just figured out that all versions, even the unmodified I copied from you, result in a crash after the debug mode run for about 4 minutes. This is caused by a "Error E1515: Invalid arguments". According to the manual, this means that "a function is called with a wrong number of types of arguments".

This very confusing and the manual isn't very helpfull either :-(
I just wanted to add, I'm very happy to have such excellent help here online. Without you I really wouldn't know what to do.
So thank you very, very much!

Re: listing strings in rows/Liste aus Strings [Re: Zalon] #132591
06/01/07 21:55
06/01/07 21:55
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
A char array is handled as a seuqence of characters. And this sequence ends with '\0'.

so if you referemce the 2nd cell of the char array, it will continue utnil it stumbles upon '\0'.

A single char length string would actually be a char array of 2:

char testArray[2];

testArray[0] = 't';
testArray[1] = '\0';

Re: listing strings in rows/Liste aus Strings [Re: FBL] #132592
06/01/07 22:07
06/01/07 22:07
Joined: May 2007
Posts: 19
Z
Zalon Offline OP
Newbie
Zalon  Offline OP
Newbie
Z

Joined: May 2007
Posts: 19
Okay, but I didn't modify the your arrays, they are still 0 --> "t", 1 --> "e", 2--> "s", 3 --> "t" 4 --> "\0".

So I don't understand why I'll get a "summary" from "st" in the cases (1) and (2) a single value of "t" and no "summary" in case (3) and crashes in (4) and (5)...

That doesn't seem to be consequent for me...

And when a call of testArray[2] will always give me all chars from 2 to the end, why not in case 3 and - additionally - how will I ever get only a single or a selection of values back?

Re: listing strings in rows/Liste aus Strings [Re: Zalon] #132593
06/01/07 22:12
06/01/07 22:12
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
0 --> "t", 1 --> "e", 2--> "s", 3 --> "t" 4 --> "\0".

if you point directly to 2 it will go further and further until it reaches \0 at 4. This results in "st"
if you only want "s" you have to change the array:
0 --> "t", 1 --> "e", 2--> "s", 3 --> "\0" 4 --> "\0".

cell 4 would be unused then.

Re: listing strings in rows/Liste aus Strings [Re: FBL] #132594
06/01/07 22:23
06/01/07 22:23
Joined: May 2007
Posts: 19
Z
Zalon Offline OP
Newbie
Zalon  Offline OP
Newbie
Z

Joined: May 2007
Posts: 19
Phew..
Then this won't work at all. As I wanted to store the NPC's ingame adresses the player already met in a struct, and display them like an adress book would do, these struct will always display all adresses, but not only a selection. Additionally I planned to give the player the possibility to add some entrys, too. As I don't know these "free entries", there's no way to code it with a struct or struct array..???

That's really bad.

Last edited by Zalon; 06/01/07 22:25.
Re: listing strings in rows/Liste aus Strings [Re: Zalon] #132595
06/01/07 22:32
06/01/07 22:32
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
Hm, I don't see why an address book shouldn't be possible.

Just use several strings not a single string. And to make things easier, use STRINGs.

To allow a flexible number of strings, you need some sort of list management which automaticcally allocates and frees memory.

I've written such a thing and posted it unter contributions quite some while ago.

Re: listing strings in rows/Liste aus Strings [Re: FBL] #132596
06/02/07 14:46
06/02/07 14:46
Joined: May 2007
Posts: 19
Z
Zalon Offline OP
Newbie
Zalon  Offline OP
Newbie
Z

Joined: May 2007
Posts: 19
Thanks again, I just found your contribution and will have a look at it.

hi - help me about array Strings [Re: Zalon] #132597
07/03/07 07:35
07/03/07 07:35
Joined: Jul 2007
Posts: 69
fat32 Offline
Junior Member
fat32  Offline
Junior Member

Joined: Jul 2007
Posts: 69
i want creat a array string by 8 part
i create this but i have problem
string user_name_str[8]="name1,name2,name3,name4,name5,name6,name7,name8";
tanks

Last edited by fat32; 07/03/07 07:36.

dobidob hosein_dig and max_man7000 game

HAPPY NEW YEAR !!
Re: hi - help me about array Strings [Re: fat32] #132598
07/03/07 14:50
07/03/07 14:50
Joined: Jul 2007
Posts: 69
fat32 Offline
Junior Member
fat32  Offline
Junior Member

Joined: Jul 2007
Posts: 69
PLEASE HELP ME >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


dobidob hosein_dig and max_man7000 game

HAPPY NEW YEAR !!
Re: hi - help me about array Strings [Re: fat32] #132599
07/03/07 14:55
07/03/07 14:55
Joined: Aug 2006
Posts: 652
Netherlands
bstudio Offline
User
bstudio  Offline
User

Joined: Aug 2006
Posts: 652
Netherlands
string user_name_str[8]="name1","name2","name3","name4","name5","name6","name7,"name8";

string arrays aren't supported in c-script, but i don't know about lite-c (if it would this would be it) if not you should fake the array

Last edited by bstudio; 07/03/07 18:44.

BASIC programmers never die, they GOSUB and don't RETURN.
Page 2 of 3 1 2 3

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