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
2 registered members (AndrewAMD, TipmyPip), 13,353 guests, and 5 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
arrays with strings #190523
03/27/08 18:55
03/27/08 18:55
Joined: Mar 2008
Posts: 17
Kärnten, Austria
T
Tarandur Offline OP
Newbie
Tarandur  Offline OP
Newbie
T

Joined: Mar 2008
Posts: 17
Kärnten, Austria
I am getting syntax errors if i try to define an array of strings like this:

Code:

STRING* text[1] = "text";
STRING* text[2] = "text2";
...

or :

STRING* text[2] = {"text","text2"...}



The array explanation in the manual does only show some examples with the type "var", but the same methods dont seem to work with strings.

could someone please write an simple array to show me its structure?

thanks, tarandur.

Re: arrays with strings [Re: Tarandur] #190524
03/27/08 18:57
03/27/08 18:57
Joined: Oct 2006
Posts: 873
S
Shadow969 Offline
User
Shadow969  Offline
User
S

Joined: Oct 2006
Posts: 873
i don't think you can make arrays out of strings, try using structs

Re: arrays with strings [Re: Tarandur] #190525
03/27/08 18:59
03/27/08 18:59
Joined: Feb 2008
Posts: 337
V
Vadim647 Offline
Senior Member
Vadim647  Offline
Senior Member
V

Joined: Feb 2008
Posts: 337
It's very easy - use TEXT's. (see it in manual - "TEXT"). They can be used as string arrays.
If you don't want to use TEXT* objects, you can define a struct type with STRING's.


I switched to other account since marth 2010. Guess which.
Re: arrays with strings [Re: Vadim647] #190526
03/27/08 19:00
03/27/08 19:00
Joined: Oct 2006
Posts: 873
S
Shadow969 Offline
User
Shadow969  Offline
User
S

Joined: Oct 2006
Posts: 873
yeah, TEXT is the best way to do that

Re: arrays with strings [Re: Shadow969] #190527
03/27/08 19:25
03/27/08 19:25
Joined: Mar 2008
Posts: 17
Kärnten, Austria
T
Tarandur Offline OP
Newbie
Tarandur  Offline OP
Newbie
T

Joined: Mar 2008
Posts: 17
Kärnten, Austria
Ok thanks, it works. But i cant believe there is no possibility for arrays.
(later) i tried :


STRING* text[2];

text[1] = "text";
text[2] = "text2";


im not getting any kind of errors, and i can also change values draw the text...

Re: arrays with strings [Re: Tarandur] #190528
03/27/08 19:42
03/27/08 19:42
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline
Serious User
Scorpion  Offline
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
you have to use str_cpy instead.

Code:
STRING* textStr[2];

str_cpy(textStr[0],"text");
str_cpy(textStr[1],"text2");



Re: arrays with strings [Re: Scorpion] #218731
07/30/08 08:51
07/30/08 08:51
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
I know this thread looks almost dead, but can I drop a question in here?

The above does indeed work fine but how can I define a pointer to the array?

In the case of a char it would be as follows:-

Code:
char* Testing = "qwertyuiop";
char* ThisChar;

ThisChar = Testing;
printf(ThisChar);   // will show "Testing"
ThisChar = ThisChar + 3;
printf(ThisChar);   // will show "ting"

I'm after a Pointer-to-a-structure-pointer I suppose you could call it.
Ive tried using
Code:
STRING* Testing[5];
... Fill Data ...
STRING** StrPoint;
StrPoint = Testing;
printf(StrPoint);   //will print First Element
StrPoint++;
printf(StrPoint);   //will print Second Element
and this works, until I try to pass it as a parameter to a function, then it all falls down.

Any suggestions anyone??
Thanks in advance.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial

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