This is the original PowerBasic Function:
' WaitForInputIdle(PID,opt MaxTime in ms)
' If Maxtime was reached, function returns 1 Else 0 * Default mxt=5000
FUNCTION X_CS(BYVAL h As LONG,OPT BYVAL mxt As DWORD) As LONG
LOCAL r,ProcID As LONG
If (mxt=0) THEN mxt=5000
GetWindowThreadProcessId(h,ProcID)
H = OpenProcess(%PROCESS_ALL_ACCESS,1,ProcID)
r = WaitForInputIdle(H,BYVAL mxt)
CloseHandle H
If (r<>0) THEN r=1
FUNCTION=r
End FUNCTION
1. The first thing to do is, to replace the comment-sign ' against the ;
2. Second change the Variable declarations from "AS LONG" etc. to ".l"
3. Change the API-Constants from "%PROCESS*" to "#PROCESS*"
4. Change the API Names and add a "_" at their end.
5. Remove the "THEN" from all IF .. THEN and make them Multi-Liners
6. Change all "END IF" to "Endif" and also "END SELECT" to "EndSelect"
7. SUB and Function becomes "Procedure" with the appropriate ".x" Datatype
8. "LOCAL" becomes "Protected"
9. There is no "BYREF" or "BYVAL" available. Also there is no DWORD Datatype.
Also there is not the WSTRING Datatype. In PureBasic you compile either with ANSI OR with Unicode. You can't easily mix.
Now in PureBasic it looks somehow like this:
; WaitForInputIdle(PID,opt MaxTime in ms)
; If Maxtime was reached, function returns 1 Else 0 * Default mxt=5000
;
Procedure.l X_CS(h.l,mxt.l=5000)
Protected r.l,ProcID.l
GetWindowThreadProcessId_(h,ProcID)
H = OpenProcess_(#PROCESS_ALL_ACCESS,1,ProcID)
r = WaitForInputIdle_(H,mxt)
CloseHandle_(H)
If (r<>0)
r=1
EndIf
ProcedureReturn r
EndProcedure