Share via


SYS(2335) - Unattended Server Mode

Enables or disables modal states for distributable Visual FoxPro .exe automation servers.

SYS(2335 [, 0 | 1])

Return Value

Character

Parameters

  • 0
    Enables unattended mode. When unattended mode is enabled, a Visual FoxPro error is generated whenever a modal state occurs. Your .exe automation server can trap for these errors with an ON ERROR routine.

  • 1
    (Default) Disables unattended mode. Modal states, which require user intervention, can occur. Unattended mode is disabled at startup.

Remarks

Use SYS(2335) to enable or disable modal states in Visual FoxPro .exe automation servers. Automation servers are created with the Project Manager. For additional information about using Visual FoxPro to create .exe automation servers, see Sharing Information and Adding OLE.

Modal states occur when dialogs or errors messages are displayed, requiring input from a user to exit the dialog or error message and continue program execution. Modal states can be undesirable in .exe servers that are deployed remotely, possibly without intervention from a user. Program execution is halted, and requires intervention for program execution to continue.

The following table lists some typical examples of modal states that can occur in an .exe server.

Modal State

Examples

WAIT command or MESSAGEBOX( ) function

Can occur in program code.

Visual FoxPro errors such as "File access is denied" or "Allowed DO nesting level exceeded"

Can occur in program code.

Open dialog boxes

Can occur when files included in a SQL statement cannot be located.

SQL Connection Login dialog box

Can occur after a connection cannot be established.

SYS(2335 ,0) should be executed as soon as possible in unattended .exe automation server program code because a modal state can occur anytime after program execution begins.

Note that SYS(2335) applies only to .exe automation servers for which the StartMode property equals 2 or 4. Unattended mode is always enabled for in-process .dll automation servers (for which the StartMode property equals 3).

Issuing SYS(2335) without an argument in a runtime application returns its current setting.

Example

The following example allows you to run several test cases to show the results of SYS(2335) settings in an application that invokes modal user interface elements.

CLEAR 
SET SAFETY OFF   
DIMENSION aTestCase[3]
aTestCase[1]="TestMessageBox"
aTestCase[2]="LocateFileDialog"
aTestCase[3]="SafetyDialog"

TEXT TO cstr  TEXTMERGE 

PROCEDURE Temp(UIMode as string,cTestCase as string) 
* command line parms are strings
  SYS(2335,VAL(UIMode))   && allow or disallow UI

  SET SAFETY OFF 
  TRY
    _screen.Caption="UIMode = "+UIMode+" "+cTestCase+" Startmode="+TRANSFORM(_vfp.StartMode)

    DO CASE 
      CASE cTestCase="<<aTestCase[1]>>"
        MESSAGEBOX("UI is allowed. UIMode = "+UIMode,0, cTestCase)
      CASE cTestCase="<<aTestCase[2]>>"
        *Try this scenario which will bring up a dialog
         SELECT * FROM NonExistFile 
      CASE cTestCase="<<aTestCase[3]>>"
        *Cause "Overwrite existing file dialog to appear"
        SET SAFETY ON 
        CREATE TABLE temp (name c(10),data m)
        CREATE TABLE temp (name c(10),data m) && Create table again to cause Overwrite dialog?
      OTHERWISE
        MESSAGEBOX("Unknown test case. UIMode = "+UIMode+" "+cTestCase)
    ENDCASE 

  CATCH TO oEx
    SYS(2335,1) && Allow UI
    MESSAGEBOX("Err caught UIMode = "+UIMode+":"+oEx.Message + " " +oEx.details,48,"Exception "+cTestCase)
  ENDTRY

ENDTEXT
STRTOFILE(cstr,"temp.prg")
BUILD PROJECT temp FROM temp
BUILD EXE temp FROM temp
FOR nTestCase=1 TO ALEN(aTestCase)
  FOR uiMode=1 TO 0 STEP -1
   ?"UIMode=",uiMode,aTestCase[nTestCase]
   cCmd="temp "+TRANSFORM(uiMode)+" "+aTestCase[nTestCase]
   ! &cCmd
  ENDFOR
  EXIT && comment this to run the other test cases
ENDFOR

See Also

Reference

SYS( ) Functions Overview

ON ERROR Command

StartMode Property