Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 642 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Pointer-trouble with dataAppendRow() #480548
06/14/20 11:47
06/14/20 11:47
Joined: Dec 2014
Posts: 206
Germany
Smon Offline OP
Member
Smon  Offline OP
Member

Joined: Dec 2014
Posts: 206
Germany
When I'm running the script below, I'm getting this:


Quote

...
Rows: 91
Values sent : wdate() = 42011.87500, price = 1.18396, atr = 0.00221
Values received: wdate() = 42011.87500, price = 0.00000, atr = 1.89799
...


The values in the 2nd and 3rd line should be exactly the same. I must be doing something wrong, but what's my mistake?

This is my script:

Code
function run() 
{
	int cols = 3; //number of columns of the dataset
	int handle = 100; //can be any number between 1..1000
	
	if(is(INITRUN))
	{
		dataNew(handle, 0, cols); 
	}

	var* row = dataAppendRow (handle, cols);
	row[0] = wdate();   //mandatory for datasets
	row[1] = price();     //just some data
	row[2] = ATR(30);  //just some data
	
	int rows = dataSort(handle); //make sure, timestamps are in descending order
	int idx = dataFind(handle, wdate());
	
	printf("\n\nRows: %d", rows);
	printf("\nValues sent      : wdate() = %.5f, price = %.5f, atr = %.5f", wdate(), price(), ATR(30));
	printf("\nValues received: wdate() = %.5f, price = %.5f, atr = %.5f", dataVar(handle, idx, 0), dataVar(handle, idx, 1), dataVar(handle, idx, 2));
}


Sorry for reposting this problem. I deleted the old thread because my demo script was too complicated.

Last edited by Smon; 06/14/20 11:56.
Re: Pointer-trouble with dataAppendRow() [Re: Smon] #480823
07/17/20 07:29
07/17/20 07:29
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
In case you have not found the problem yet, it's here:

var* row = dataAppendRow (handle, cols);

A var is 8 bytes, but the elements of a database record, except the first, have a size of 4 bytes.


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