Gamestudio Links
Zorro Links
Newest Posts
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
Release 2.68 replacement of the .par format
by Martin_HH. 09/23/25 20:48
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
1 registered members (dBc), 17,435 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
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: 28,022
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,022
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 | 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