So I’m trying to create an array which is save specific, which I’m doing by using GDT.DataStore.data. However, it doesn’t seem as if it’s possible to use this object for arrays, though that might be because of my lack of knowledge and experience with arrays. I’ve uploaded my code to pastebin, which should probably make it easier to read rather than pasting it on here. From what I can see, this piece of code should be running without any problems. However, it isn’t.
I’d like to know whether or not it’s possible to use GDT.getDataStore.data as an array (and if not, if there’s a possible workaround for what I’m trying to do) or if I’m doing something completely wrong.
Yes, I know this, and this is exactly what I have done, is it not? I appreciate you two helping me, but I’m afraid I don’t quite understand what you two are trying to say.
You should also make GDT.getDataStore("FMPASTRACT").data into a variable so its a bit quicker Have you created the array before you push to it? Doesn’t seem like it.
This should be YP as YP is the difference between the last item in the array and the item before the last. What I’m in theory doing (well, trying to do) is:
var d = GDT.getDataStore("FSMPASTRACT").data
d.YPA = [0, 4, 5, 9]
d.YP = 9 - 5
Line 1: Missing semicolon
Line 12: I don’t know exactly how it is, but I didn’t think you could just do “- calculation * 9” without having it predefined as a variable. Thats throws runtime exception in C++/C, Java and C#.
I’ve made it to where it should calculate 20% of YP before subtracting it, however this doesn’t change a thing as I’m still getting ‘GDT event handler error’ on M1 W1. When I try to get it to show me the value of YPA[0] and YPA[1] it doesn’t show anything too, so I’m still convinced it has something to do with the array.
Try to remove the array and just have values like “ypaMoney” instead. Messy, I know Btw, you should try using an object instead of array. Works better.
The thing about using the array is that I can (well, in theory I should be able to) add a value to it and subtract it with the previous value. By making two or more objects to calculate the yearly profit, I don’t see how I would be able to calculate the profit of year 2 after calculating the profit of year 1, whilst keeping the same value of the amount of cash the company had at the end of year 1, at the end of year 2, if that makes any sense.
EDIT: Nevermind, I’ve figured out an alternative way of doing it, and it worked when I tested it. Thank you both for giving up your time to help me.