I searched the whole site and didn't find any posts on this. If I pass a constant value, the Sleep API works fine in sub-procedures(Sleep(4)). If I pass a variable name I get varying results (Sleep(SleepSeconds)). If the value comes from another variable that is packed the sleep command takes 15 seconds no matter what the value in the variable is. If it is assigned to a constant, the Sleep API does not stop. If the Sleep API is run in a different sub-procedure it doesn't stop running no matter how the variable was populated. If I place the Sleep prototype in the sub-procedure it does not make a difference. This is running on OS 7.2 currently and will be running on 7.4 soon. Thanks.
Global Declaraions:
Dcl-S SleepSeconds Uns(10); // Sleep time
Dcl-Pr Sleep ExtProc('sleep');
*n Uns(10) Const;
End-Pr;
Dcl-Proc $Init_Process;
GetConfig(ReturnCode:SyPcn);
If ReturnCode <> 'Fail';
SleepSeconds = Amt1cn; // Packed 7.0 from External DS
Else;
SleepSeconds = 2;
EndIf;
Sleep(SleepSeconds); // Test Sleep Function
Dcl-Proc $Proc_WebServ;
Dcl-Pi *N Ind;
End-Pi;
Sleep(SleepSeconds); // Test Sleep Function
Sleep API not working correctly in sub-procedures
Re: Sleep API not working correctly in sub-procedures
Your prototype is wrong. You are passing by reference (a pointer) when sleep() - as do most C library functions- requires the value be passed by VALUE.
You code is never seeing the value you set - rather it is using the pointer to that value which could equate to any period of time.
Proto should be:
You code is never seeing the value you set - rather it is using the pointer to that value which could equate to any period of time.
Proto should be:
Code: Select all
Dcl-Pr Sleep ExtProc('sleep');
*n Uns(10) Value;
End-Pr;
Re: Sleep API not working correctly in sub-procedures
Thank you jonboy49. I should have caught that. It works now.