automatically closing program if condition is met

Started by Shawn Anderson, August 31, 2009, 05:07:20 PM

Previous topic - Next topic

Shawn Anderson

I have a program that reads the value of command$.
If command$ is blank, I want to quit the program.
How do I do that?
I've tried

Function MAINFORM_WM_CREATE ( _
                            hWndForm As Dword, _  ' handle of Form
                            ByVal UserData As Long _  'optional user defined Long value
                            ) As Long                     
                           
Local clientID As String

clientID=Command$

If Trim$(clientID)="" Then
MsgBox "client ID not passed to NBSscan.exe",,$mTop   
MAINFORM_WM_Destroy (hWndForm)

End If

End Function   


but that doesn't work

David Kenny

Check Command$ in FF_WinMain (found in FireFly Workspace in the special functions folder).

Paul's comments in the routine tell you what to do if you want to exit the program.

Regards,

David

Shawn Anderson


TechSupport

David is spot on with his advice:


Function FF_WINMAIN( ByVal hInstance     As Dword, _
                     ByVal hPrevInstance As Dword, _
                     ByVal lpCmdLine     As Asciiz Ptr, _
                     ByVal iCmdShow      As Long ) As Long


   ' If this function returns TRUE (non-zero) then the actual WinMain will exit
   ' thus ending the program. You can do program initialization in this function.

   If Len(RTrim$(Command$)) = 0 Then
      Function = %TRUE
   End If
     
   ' Function = %FALSE    'return %TRUE if you want the program to end.

End Function