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
2 registered members (AndrewAMD, dr_panther), 1,271 guests, and 4 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
How can I work with a STRING* [ ]? #117921
03/17/07 20:13
03/17/07 20:13
Joined: Nov 2005
Posts: 94
Texas
3
3Dski Offline OP
Junior Member
3Dski  Offline OP
Junior Member
3

Joined: Nov 2005
Posts: 94
Texas
I can declare a STRING* array, but cannot seem to use the LiteC string functions on the elements. I did discover that I can simply initialize an element using "=". But, if I try to use str_cat() to append to any of these:

Code:
 
STRING* mystrings[2];

mystrings[0] = "some string";
mystrings[1] = "another";
...
str_cat( mystrings[0]," one");


I get "Invalid arguments in LiteC." What are the rules for working with arrays of type STRING*?

Re: How can I work with a STRING* [ ]? [Re: 3Dski] #117922
03/17/07 20:54
03/17/07 20:54
Joined: Jan 2006
Posts: 1,829
Neustadt, Germany
T
TWO Offline

Serious User
TWO  Offline

Serious User
T

Joined: Jan 2006
Posts: 1,829
Neustadt, Germany
STRING* mystrings[2];

str_cpy(mystrings[0], "some string");

This should work;

Re: How can I work with a STRING* [ ]? [Re: TWO] #117923
03/17/07 21:10
03/17/07 21:10
Joined: Nov 2005
Posts: 94
Texas
3
3Dski Offline OP
Junior Member
3Dski  Offline OP
Junior Member
3

Joined: Nov 2005
Posts: 94
Texas
One think your str_cpy() would work with the array element, but it doesn't. And, here's an interesting twist... if the second argument to one of LiteC's string functions is an element of a string[], it will accept this:

Code:

STRING* plain = "a string";
STRING* strarray [2];
strarray[0] = " appended 1";
strarray[1] = " appended 2";

str_cat( plain, strarray[0]); // ...good
str_cat( plain, strarray[1]); // ...good
str_cat( plain, " bla,bla"); // ...good

str_cat( strarray[0], plain); // ... invalid arguments error
str_cat( strarray[0], " something"); // ... invalid arguments error



It's almost like the compiler sees a STRING* [] element as a char*!

Re: How can I work with a STRING* [ ]? [Re: 3Dski] #117924
03/18/07 12:08
03/18/07 12:08
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline
Expert
Excessus  Offline
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
I think you must str_create them. STRING is a struct with a number of members. For example a char[] for the contents, a length variable and a pointer to the next element in the internal linked list. str_create is used to initialise all these correctly.

STRING* mystr[3];
mystr[0] = str_create();

Then use it like you would in c-script.

Re: How can I work with a STRING* [ ]? [Re: Excessus] #117925
03/19/07 00:59
03/19/07 00:59
Joined: Nov 2005
Posts: 94
Texas
3
3Dski Offline OP
Junior Member
3Dski  Offline OP
Junior Member
3

Joined: Nov 2005
Posts: 94
Texas
Thanks, I'll try that technique. Tell you the truth, I didn't notice a str_create(). I'll research that, try it out and report back it I'm having unexpected problems.

EDIT: Works great, now that I know about the str_create()... that was the ticket. I'm now surprised that it wouldn't complain about setting a string* with = and a string constant

Last edited by 3Dski; 03/19/07 02:40.

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