Commands not going in order

I am not sure if this is a photon/PhAB problem or if it is a C problem to be honest. I have a function wait(n) where n is the number of seconds it should idle. The context is I hit a button, it says “Testing…” for the duration, then hides the Testing label after the n seconds. My problem is that even though I put the PtRealizeWidget() before wait(5), during runtime, it will wait the full time, then realize the widget after the time has elapsed. Here is the wait function and the way it is set up in my program.

void wait(int seconds)
{
clock_t endwait;
endwait = clock() + seconds * CLOCKS_PER_SEC;
while(clock() < endwait) {}
}


{

PtRealizeWidget(ABW_testing);
wait(5)
PtUnrealizeWidget(ABW_testing);

}

If I take out the unrealize function, it will realize after the waiting, but I cannot get it to realize before. Any suggestions as too why this would be?

This won’t work because you are not returning to the photon processing loop.
You can call PtFlush after PtRealizeWidget for immediate processing.

It seems to me you need to re-read the photon architecture and programming guides.
Good luck.

That did it, thanks. Another issue I just ran into is that when I call PtSetResources, to change the time remaining in a label, I call:
PtSetResource(ABW_time_remaining, Pt_TEXT_STRING, num, 0);
Where num is a string with the number in it. My problem is that when I compile, it says that PtSetResource was not prototyped and errors out, but I made sure (and PhAB did it for me) to include Pt.h. Is there something more that has to be done? I’ve gone through the programmer’s guide and function library and cannot figure this out. Thanks.

Edit: I was able to get resources set by using SetArg and SetResources, not sure why SetResource doesn’t work still.

Ok that worked fine for having a timer when nothing is happening in the background, but now I need an abort button to quit it early in the case that the user wants to. Like you said, it’s not in the photon main loop, so is there a way to continue allowing photon to run while waiting for real time to pass to do something (like update the timer)?

Edit:
PtBkgdHandlerProcess() will allow photon to continue working. In my base, I put it into the empty while loop, works perfectly.

PtSetResources not PtSetResource

PtSetResources has only three arguments i.e PtSetResources(widget, numargs, argarray)

you set up the args with PtSetArg and then callPtSetResources to set those args

e.g

PtArg_t arg;
char *num;

setup num then

     PtSetArg (&arg, Pt_ARG_STRING_TEXT, &num, 0);
     PtSetResources(widget, 1, &arg);

like I said before, it’s all in the programmers guide.
I think the section is called “Manipulating Resources In Application Code”.

Well if you look a bit further in that chapter, it does address PtSetResource, singular. Maybe it’s a newer version and I have an old one. I don’t know. Either way, thanks for helpin’ out. Much appreciated.