Gamestudio Links
Zorro Links
Newest Posts
Mixed frequency history (M1+D)
by jcl
Today at 12:21
New Zorro version 2.12
by jcl
Today at 11:48
This is my fault-tolerant ATR indicator for you
by OptimusPrime
05/18/19 16:35
missing trade variables
by AndrewAMD
05/18/19 12:37
export asset to .txt file
by sdh309795gaas
05/17/19 16:21
LookBack mysteries
by sdh309795gaas
05/17/19 06:28
It is easy for you.
by AndrewAMD
05/16/19 16:39
AUM Magazine
Latest Screens
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Who's Online
11 registered (AndrewAMD, kvm, jumpman, mk_1, Dalla, MatPed, FLD, Realspawn, JeyKey II, 1 invisible), 460 Guests and 6 Spiders online.
Key: Admin, Global Mod, Mod
Newest Members
h4h4rd, ccm, Pippo, hurleydood, JohnLouderback
18222 Registered Users
Topic Options
Rate This Topic
#474923 - 11/13/18 13:59 Document AssetInt and AssetFloat
AndrewAMD Online

Registered: 02/21/17
Posts: 652
Loc: Chicago

I think it would be useful for the manual to:
* Document AssetInt and AssetFloat
* Document how to avoid the problems I encountered, below.

- - - - -

I recently had the privilege to work on a custom indicator, where it seemed very practical to store some binary switches in an integer on a per-asset basis.

I dug into the headers, and I found these #define's:

#define AssetVar		(g->asset->Skill)
#define AssetStr		(char*)&(g->asset->Skill)
#define AssetInt		((int*)AssetVar)
#define AssetFloat		((float*)AssetVar)

... where Skill is a var array with 16 elements.

Cool, so I can use an AssetInt. Here was my naive implementation:

#define V0 AssetVar[0]
#define V1 AssetVar[1]
#define V2 AssetVar[2]
#define I3 AssetInt[3]

It took me an hour of debugging to figure out if and why my I3 int was giving me garbage values. Here was my fix:

#define V0 AssetVar[0]
#define V1 AssetVar[1]
#define V2 AssetVar[2]
#define I3 AssetInt[3*2]

As you can see, I had to double the array offset to position my integer correctly. In other words, I3 was originally at position 1.5 on the var array, so if I change the value of V1, it transforms I3 into a garbage value. The fix has I3 at position 3 of the var array, as desired.

As an added bonus, this means that the script writer can have:
* Up to 16 AssetVars, or
* Up to 16 AssetStrs (7 characters before null termination each), or
* Up to 32 AssetInts, or
* Up to 32 AssetFloats, or
* Any mix-and match of the above, with the appropriate pointer arithmetic.

#474935 - 11/14/18 09:07 Re: Document AssetInt and AssetFloat [Re: AndrewAMD]
jcl Online

Chief Engineer

Registered: 07/22/00
Posts: 26866
Loc: Frankfurt
We had not documented these macros because they were for internal use only. But we'll add them officially in the next update.

#474946 - 11/14/18 15:23 Re: Document AssetInt and AssetFloat [Re: jcl]
AndrewAMD Online

Registered: 02/21/17
Posts: 652
Loc: Chicago
Thank you!


Moderator:  aztec, Inestical, Matt_Coles, Tobias 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at)