Thebattlefront Posted February 15, 2022 Report Share Posted February 15, 2022 Hello, I have been having a bit of trouble getting arrays to work with the CurrentState variables. For example: This line of code: Works without any issues. The debugging log and the chart shows the correct PBShapes and Colors for those shapes, so I know the code is working. However, if I were to declare a new CurrentState variable in this way: } } And then subsequently write the line of code: The debugging log below the code lines does not return any immediate error in the coding. However, a red "X" displays on the Chart next to the PaintBar's name in the top left and the PBShapes and Colors don't show on the chart as well. So I was wondering if I have declared or defined something incorrectly, or if possibly the CurrentState function doesn't support array type variables. Quote Link to comment Share on other sites More sharing options...
Thebattlefront Posted February 15, 2022 Author Report Share Posted February 15, 2022 (edited) Wow I really messed up the formatting. How do i delete this lol I will rewrite it here again instead: Is it possible to declare and use a CurrentState variable as an array? Hello, I have been having a bit of trouble getting arrays to work with the CurrentState variables. For example: This line of code: double[] abc_Vector = {1, 2, 3, 4}; double abc = abc_Vector[1]; Works without any issues. The debugging log and the chart shows the correct PBShapes and Colors for those shapes, so I know the code is working. However, if I were to declare a new CurrentState variable in this way: private void PaintbarInitialize() { CurrentState.m_dTest = new double[4] {0, 0, 0, 0}; } private struct PaintbarState { public double[] m_dTest; } And then subsequently write the line of code somewhere in any another function: double abc = CurrentState.m_dTest[1]; The debugging log below the code lines does not return any immediate error in the coding. However, a red "X" displays on the Chart next to the PaintBar's name in the top left and the PBShapes and Colors don't show on the chart as well. So I know something running inside the program is having a problem. And the only thing that I've changed from the working program, to the one that is not working, is the declaration of the CurrentState array variable. So I was wondering if I have declared or defined something incorrectly, or if possibly the CurrentState function doesn't support array type variables. EDIT: Apparently I can't copy paste code from the Paintbar directly into a post. It turns up empty. EDIT: I typed it in manually instead Edited February 15, 2022 by Thebattlefront Quote Link to comment Share on other sites More sharing options...
Jerry Medved Posted February 15, 2022 Report Share Posted February 15, 2022 email it? Quote Link to comment Share on other sites More sharing options...
Thebattlefront Posted February 15, 2022 Author Report Share Posted February 15, 2022 Yessir Jerry I shall email it to you. Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted February 15, 2022 Report Share Posted February 15, 2022 The problem is (for those who write paintbars) PaintbarInitialize is called FIRST. Then PaintbarClearState. If you initialize your state variable in PaintbarInitialize, the ClearState will wipe it out. I changed the functions' descriptions in the code to explain this. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.