Needed to generate a time much shorter than the standard 0.01 seconds minimum - need to go down to at least 100 microseconds (i.e. 10Khz) - it's to communicate to a purpose-made PCI card. A simple one button app was made:
Sub MAIN_Events(CID&, CMsg&, CVal&, Cancel&)
Select Case CID&
Case %EZ_Window
Select Case CMsg&
Case %EZ_Loading
Case %EZ_Loaded
Case %EZ_Started
AppMain
Case %EZ_Close
'Do ' THIS
' Sleep 1 ' DOES
' EZ_UnloadForm "Main" ' NOT
'Loop ' WORK
Case Else
End Select
Case Else
End Select
End Sub
Sub MAIN_BUTTON1_Events( MyID&, CMsg&, CVal&, Cancel&)
Select Case CMsg&
Case %EZ_Click
Terminate = 1
Case Else
End Select
End Sub
Sub AppMain()
Do
If Terminate > 0 Then Exit Do
PCI
EZ_DoEvents 25
Loop
EZ_UnloadForm "Main"
End Sub
All works well so far - getting 60KHZ plus at the PCI and the CPU is at only 50% (not an issue as it's the only app that will run on this PC).
The button "Button1" sets a variable ("Terminate") to 1, breaking the loop and causing the app to terminate.
Only issue - the red X system menu button does not word correctly (app exits but doesn't terminate and has to be killed off in task manager). The commented out code above doesn't work either.
Disabling this with the D property on the form is our workaround for now - but the users want the red X back.
Setting Cancel& to 1 stops EZ_UnloadForm from working, so that's not an option either.
Is there a way of getting the red X to not exit but to instead just set Terminate to "1", just as if the user clicked "Button1"?