Confusing Syntax Error with Pointers

Hello guys,

I seem to be having an issue understanding why my code won’t compile, this code is in a block within a subroutine.

below I have posted my code along with the compilation errors

// if Ramp start > Setpoint move analog to set point (this prevents unexpected ramping to 100%)
if (*pft_Setpoint[*pn_Index] <= *pft_RampStart[*pn_Index]) then
  *pao_AnalogOutput = pft_Setpoint[*pn_Index];
else
  // Start analog point at ramp start
  *pao_AnalogOutput = *pft_RampStart[*pn_Index];
  //ramp analog to setpoint
  RampAnalogOutput(*pft_Setpoint[*pn_Index], *pft_RampRate[*pn_Index], *pao_AnalogOutput);
endif

Compiling…
Error on line 2: syntax error at or near “[”
Error on line 2: syntax error at or near “)”
Error on line 3: syntax error at or near “[”
Error on line 8: syntax error at or near “[”
Error on line 8: syntax error at or near “,”
5 error(s), 0 warning(s)

It may be with the way I am using pointers, if you have any idea why I am having these issues please reply!

Maybe its just confused and might need to be broken down a bit.
How about making a integer variable idx, then do idx = *pn_Index;
[idx] instead of [pn_Index]
See if that helps.

Is pft_Setpoint a pointer to a float table?
Is pn_Index a pointer to an integer variable?

Your 3rd line isn’t being dereferenced on pft_Setpoint as well.

Yes they are, Oops didn’t notice that one, I fixed that one issue

I was thinking of doing this but was hoping I could avoid doing that, how my subroutine is setup is I pass about 12 arguments through a pointer table then I have pointers within the subroutine to take those values so I can dereference and utilize them.

Are you sure? That is the only thing I can see wrong is that the types are not correct for what you are trying to do.

2 Likes

Went back to double check my pointer types:

pao_AnalogOutput is set to point to an analog output
pft_Setpoint was set to Down Timer, I fixed it and made it point to a float table
pn_Index is set to point to Integer 32 Variable
pft_RampStart is set to point to float table

Thank you so much turns out it was because of pft_Setpoint pointing to the wrong datatype

1 Like