PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Shawn Anderson on August 31, 2009, 05:07:20 PM

Title: automatically closing program if condition is met
Post by: Shawn Anderson on August 31, 2009, 05:07:20 PM
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
Title: Re: automatically closing program if condition is met
Post by: David Kenny on August 31, 2009, 06:56:06 PM
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
Title: Re: automatically closing program if condition is met
Post by: Shawn Anderson on August 31, 2009, 07:11:13 PM
that was it, thanks
Title: Re: automatically closing program if condition is met
Post by: TechSupport on August 31, 2009, 07:13:22 PM
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