************************************************************************ FUNCTION InputForm ****************** *** Function: Creates a simple Input form that returns a value *** Assume: Consists of this function and Form Class *** Pass: lcValue - Initial value to retrieve *** lcMessage - The request message *** lcCaption - Form Caption (_Screen.Caption) *** lnFormWidth Width of the form *** lnFieldWidth Widht of the input field *** lcFormat Format string for the input field *** "PASSWORD" to show password entry *** lcCancelValue Value returned on a Cancel operation *** Return: Value or ("" or -1) ************************************************************************ LPARAMETER lcValue, lcMessage, lcCaption, lnFormWidth, lnFieldWidth, lcFormat,lcCancelValue PRIVATE pcResult LOCAL o IF PCOUNT() > 6 pcCancelValue = lcCancelValue ELSE pcCancelValue = NULL ENDIF lcValue=IIF(EMPTY(lcValue),"",lcValue) lcMessage=IIF(EMPTY(lcMessage),"Please enter",lcMessage) lcCaption=IIF(EMPTY(lcCaption),_SCREEN.Caption,lcCaption) lnFormWidth=IIF(EMPTY(lnFormWidth),300,lnFormWidth) lnFieldWidth=IIF(EMPTY(lnFieldWidth),lnFormWidth - 20,lnFieldWidth) lcFormat=IIF(EMPTY(lcFormat),"@K",lcFormat) lcType = VARTYPE(lcCancelValue) pcResult = lcValue o=CREATE("frmInput") o.Width = lnFormWidth o.nFieldWidth = lnFieldWidth o.Caption = lcCaption o.cMessage = lcMessage o.cFormat = lcFormat IF lcFormat = "PASSWORD" o.cFormat = "@K" o.txtInput.Fontname="Symbol" o.txtInput.PasswordChar = "¨" ENDIF o.Show() IF TYPE("pcResult")="C" lcValue = TRIM(pcResult) ELSE lcValue = pcResult ENDIF RETURN lcValue ************************************************** *-- Form: frminput *-- ParentClass: form *-- BaseClass: form DEFINE CLASS frminput AS form nFieldWidth = 250 cMessage = "Please enter:" cFormat = "" Top = 0 Left = 0 Height = 90 Width = 300 ControlBox = .F. Name = "frmInput" WindowType = 1 AutoCenter = .t. Showwindow = 1 BorderStyle = 2 MinButton = .f. ShowWindow = 1 MaxButton = .f. ADD OBJECT lblMessage AS label WITH ; AutoSize = .T., ; Caption = "Message Text:", ; Height = 17, ; Left = 7, ; Top = 11, ; Width = 81, ; Name = "lblMessage",; Font = "Tahoma" ,; FontSize = 8 ADD OBJECT txtinput AS textbox WITH ; ControlSource = "pcResult", ; Height = 22, ; Left = 5, ; Top = 28, ; Width = 373, ; Name = "txtInput",; Font = "Tahoma" ,; Default = .T.,; FontSize = 8 ADD OBJECT cmdOk AS commandbutton WITH ; Top = 55, ; Left = THISFORM.width - 150, ; Height = 25, ; Width = 70, ; Caption = "OK", ; Default = .T., ; Fontname="Tahoma",; Fontsize = 8,; Cancel = .F.,; Name = "cmdOK" ADD OBJECT cmdCancel AS commandbutton WITH ; Top = 55, ; Left = THISFORM.Width - 75, ; Height = 25, ; Width = 70, ; Caption = "\<Cancel", ; Fontname="Tahoma",; Fontsize = 8,; Cancel = .T.,; Name = "cmdCancel" PROCEDURE Show THIS.Icon = _Screen.icon THIS.txtInput.Width = THIS.nFieldWidth THIS.lblMessage.Caption = THIS.cMessage THIS.cmdCancel.Left = THISFORM.Width - 85 THIS.cmdOk.Left = THISFORM.Width - 157 IF !EMPTY(THIS.cFormat) IF ATC("@",THIS.cFormat) > 0 THIS.txtInput.Format = THIS.cFormat ELSE THIS.txtInput.InputMask = THIS.cFormat ENDIF ENDIF ENDPROC PROCEDURE cmdOk.Click RELEASE THISFORM ENDPROC PROCEDURE cmdCancel.Click LOCAL lcType IF ISNULL(pcCancelValue) lcType = TYPE("pcResult") DO CASE CASE lcType $ "CM" pcResult = "" CASE lcType $ "NIBY" pcResult = -99999999 CASE lcType $ "DT" pcResult = {} CASE lcType = "L" pcResult = .f. ENDCASE ELSE pcResult = pcCancelValue ENDIF RELEASE THISFORM ENDPROC ENDDEFINE * *-- EndDefine: frminput **************************************************You can use the format parameter to specify a format flag or inputmask.