Pointer to an Up Timer

I’ve created a pointer table containing pointers to a series of up timers. Here’s an example of how the table values are assigned, see below.

SetUpTimerTarget(60, Timer_sec); 
ptTimerTable[0] = &Timer_sec;

I then start the time in later code, see below.

StartTimer(*ptTimerTable[0]);

When Test Compiling I get the following syntax error.

Unable to find variable or command “*ptTimerTable[0]”

What am I doing wrong here?

Thanks in Advance,

DKMarion

I would create a temporary (non-table) pointer to hold ptTimerTable[0] and put that temporary pointer into the StartTimer() function instead. It just brings the reference one level simpler so the function doesn’t have as much to unpack.

To add to what @torchard advised, the PAC Control User’s Guide (p. 327) describes how you can’t reference pointer tables directly.

Here are the “pointer table” forums search results:
https://forums.opto22.com/search?q=%22pointer%20table%22

I suspect others like @philip will be along at some point to offer some suggestions as well.

Back the the search results… if you check a few of them out you will find some great input related to your post.
This thread here is probably the best (second search result).

I think you know by now that you will need a pointer to an up timer to assign the pointer table to.

If you have a need for a lot of timers, instead of creating individual timers, you could create a table that holds time values. Various ways of doing this in the below post. You can also have them be persistent which is also useful.

Thanks for your help. Here’s my code. The code does compile.

SetUpTimerTarget(60, Timer_sec); 
ptTimerTable[0] = &Timer_sec;

TimerUpPointer_sec = ptTimerTable[0];
StartTimer(*TimerUpPointer_sec);

Dale

2 Likes