Gamestudio Links
Zorro Links
Newest Posts
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
folder management functions
by 7th_zorro. 04/15/24 10:10
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
LPDIRECT3DCUBETEXTUR
E9

by Ayumi. 04/12/24 11:00
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 04/11/24 14:56
SGT_FW
by Aku_Aku. 04/10/24 16:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (7th_zorro, Aku_Aku), 319 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
11honza11, ccorrea, sakolin, rajesh7827, juergen_wue
19045 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Saving a string with more than 3 characters in a dataset #482911
04/16/21 09:31
04/16/21 09:31
Joined: Apr 2021
Posts: 14
V
VizTra Offline OP
Newbie
VizTra  Offline OP
Newbie
V

Joined: Apr 2021
Posts: 14
Hello,

I'd like to know, how to save a string in a dataset that is bigger than 3 characters.

What I've got so far:

Quote
dataNew(1, NumAssetsListed, 3);

string tickerString = dataStr(1, 0, 1);
strcpy(tickerString, "AAPL");

dataSet(1, 0, 2, 0.05);
dataSaveCSV(1, "f0,sss,f2,f3", "AppleMomentum.csv");


What I know so far is, that when importing a .csv you can select the format and in that case you can import the csv with a format contain "sss" to import strings bigger than 3 chars. But what about creating completeley new datasets within Zorro?
I create a dataset with dataNew() and then take the pointer to the string field via dataStr(), without being able to somewhere make sure the string can be bigger than 3 characters.

I'm probably missing something.

Kind regards,

Re: Saving a string with more than 3 characters in a dataset [Re: VizTra] #482920
04/16/21 14:51
04/16/21 14:51
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
You can store a string as long as you want, but you need to reserve one more field for any 4 more characters. Those fields then hold a part of the string and cannot contain numbers.

Re: Saving a string with more than 3 characters in a dataset [Re: VizTra] #483590
06/17/21 19:16
06/17/21 19:16
Joined: Jun 2021
Posts: 3
Brazil
D
damasceno Offline
Guest
damasceno  Offline
Guest
D

Joined: Jun 2021
Posts: 3
Brazil
Hi, I'm having a similar difficult.

I can include the string in the dataset but when I export to .csv the first column/row doesn't appear the strings. But if I add the string to another column and row its ok.

Adding to the first column [0]:

Quote

string FormatA = "sss,f,f,f";
function evaluate()
{

dataNew(2, 10, 4);
string statistic = dataStr(2, 0, 0);
strcpy(statistic, "testing");

watch("!i",dataStr(2,0,0));
dataSaveCSV(2,FormatA,"History\\test.csv");



.csv result ->" ,0.00000,0.00000,0.00000,0.00000,0.00000"

changing dataStr to dataStr(2,1,0) -> .csv first line result -> "0.00000,,0.00000,0.00000,0.00000,0.00000"

dataStr(2,1,1) -> .csv second line result -> "0.00000,testing,0.00000,0.00000,0.00000"

Is there a way to add strings to the first column/row, or I'm doing something wrong?

Thanks!

Re: Saving a string with more than 3 characters in a dataset [Re: VizTra] #483595
06/18/21 06:32
06/18/21 06:32
Joined: Apr 2008
Posts: 585
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 585
Austria
Your dataset has wrong number of fields. For 6 fields its dataNew(...6), not 4.

Re: Saving a string with more than 3 characters in a dataset [Re: Petra] #483598
06/18/21 18:16
06/18/21 18:16
Joined: Jun 2021
Posts: 3
Brazil
D
damasceno Offline
Guest
damasceno  Offline
Guest
D

Joined: Jun 2021
Posts: 3
Brazil
Yes, I simulated with dataNew(...6) but copied the code with dataNew(...4) here, but the problem is the same

Re: Saving a string with more than 3 characters in a dataset [Re: VizTra] #483599
06/18/21 20:38
06/18/21 20:38
Joined: Jul 2017
Posts: 783
Z
Zheka Offline
User
Zheka  Offline
User
Z

Joined: Jul 2017
Posts: 783
"Every record begins with an 8-byte date/time field."

So, column [0] is treated as a double.

Re: Saving a string with more than 3 characters in a dataset [Re: Zheka] #483604
06/20/21 03:40
06/20/21 03:40
Joined: Jun 2021
Posts: 3
Brazil
D
damasceno Offline
Guest
damasceno  Offline
Guest
D

Joined: Jun 2021
Posts: 3
Brazil
Thanks Zheka!


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1