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
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: 28,022
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

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