Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (VoroneTZ, dr_panther, TedMar, vicknick), 831 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
Array of strings? #461740
08/18/16 20:12
08/18/16 20:12
Joined: Jun 2016
Posts: 29
panz Offline OP
Newbie
panz  Offline OP
Newbie

Joined: Jun 2016
Posts: 29
I was trying to define an array of strings to store a bunch of symbol names. I tried the following methods which should be valid in standard C, but I got syntax errors in Zorro:

const char *array[] = {"USDJPY", "EURUSD", "USDCAD"};

Or:
char **array = (char *[]){"USDJPY", "EURUSD", "USDCAD"};

Eventually I was able to work around using the following:
string symb;
while(symb = loop("USDJPY", "EURUSD", "USDCAD"))
{
...
}

But this is not ideal as I cannot reuse the array somewhere else.

Does anyone know in Zorro how I should properly initialize an array of strings? If necessary I can accept a method that requires dynamic memory allocation.

Thanks!!

Re: Array of strings? [Re: panz] #461768
08/19/16 19:00
08/19/16 19:00
Joined: May 2015
Posts: 390
Czech Republic
G
Grat Offline
Senior Member
Grat  Offline
Senior Member
G

Joined: May 2015
Posts: 390
Czech Republic
I'm use this:

Code:
#define SYMBOLS "EUR/USD","USD/JPY","NZD/USD","GBP/JPY","AUD/USD","EUR/NZD","USD/CAD","AUD/NZD","USD/CHF","EUR/GBP" 
...
...
while(loop(SYMBOLS)){
...


Re: Array of strings? [Re: Grat] #461779
08/20/16 15:34
08/20/16 15:34
Joined: Jun 2016
Posts: 29
panz Offline OP
Newbie
panz  Offline OP
Newbie

Joined: Jun 2016
Posts: 29
Thanks, looks better. :-)

Re: Array of strings? [Re: panz] #461800
08/22/16 08:25
08/22/16 08:25
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
For a bunch of symbol names, the "official" method is storing them all in an asset list, and use the "Assets" pointer for the loop.

assetList("MySymbols.csv");
....
while(asset(loop(Assets))) ...

This way you don't need to change the script when adding or removing assets.


Moderated by  Petra 

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