compile function RTI_HTTP_DOWNLOAD_TEST( object, method, param1, param2, param3, param4, param5, param6 )
/*
   ** Copyright (C) 2012-2021 Revelation Software Inc. All Rights Reserved **

   Author   : Mr C
   Date     : 
   Purpose  : Commuter module for the RTI_HTTP_DOWNLOAD_TEST form

   Comments
   ========
   
   This is a simple form used to test the RTI_HTTP_DOWNLOAD proc.

   Amended  Date        Reason
   =======  ====        ======
   Mr C     14 Dec 21   Removed System Compiler statements :)
*/
   #pragma precomp event_precomp
   
   declare function get_Property, set_Property, utility, retStack, rti_IDE_Cfg
   declare function ps_Get_Property, rti_Res2Str, msg, exec_Method, dialog_Box
   declare function rti_ErrorText
   $insert rti_Http_Download_Equates
   $insert msWin_GetOpenFileName_Equates
   $insert ps_ChooseFile_Equates
   $insert rti_IDE_PGO_TextLine_Equates
   $insert rti_IDE_Open_Equates
   $insert rti_Get_Proc_Info_Equates
   $insert rti_IDE_Cfg_Equates
   $insert rti_Resources_Equates
   $insert rti_Conv_Equates
   $insert rti_SSP_Equates
   $insert logical
   
   errorText = ""
   abort     = FALSE$
   retVal    = ""
   
   // Conversion processing - we're overloading the commuter module here to
   // keep control-specific conversion code in the same proc.
   locate object in "ICONV" using "," setting pos then
      on pos goSub onIconv
      return retVal
   end
   
   if assigned( object ) else object = ""
   if assigned( method ) else method = ""
   if assigned( param1 ) else param1 = ""
   if assigned( param2 ) else param2 = ""
   if assigned( param3 ) else param3 = ""
   if assigned( param4 ) else param4 = ""
   if assigned( param5 ) else param5 = ""
   if assigned( param6 ) else param6 = ""
   
   atCtrl = field( object, ".", 2, 99 )
   
   if bLen( method ) then
      locate method in "CHANGED,CHAR,CLICK,ENDDIALOG,GOTFOCUS,OMNIEVENT,OPTIONS,PROPCHANGED,PROPOPTIONS" using "," setting pos then
         on pos goSub onChanged,onChar,onClick,onEndDialog,onGotFocus,onOmniEvent,onOptions,onPropChanged,onPropOptions
      end else
         * // ERR002: Invalid method "%1% passed to the %2% procedure
         errorText = rti_Res2Str( RESID$, "ERR002", method : @fm : retStack()<1> )
         abort     =  TRUE$
      end
   end else
      * // ERR001: No method passed to the %1% procedure
      errorText = rti_Res2Str( RESID$, "ERR001", retStack()<1> )
      abort     =  TRUE$
   end

   if abort then
      if bLen( errorText ) then
         goSub errorMsg
         if ( method = "CREATE" ) then
            call send_Event( @window, "CLOSE" )
         end
         
      end
   end

return retVal

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////  
// onChanged subroutine
//
// Main CHANGED event dispatch handler
//
// ----------------------------------------------------------------------------
// [i]   param1 : NewData - this is the text that has changed.
// [i]   atCtrl : ID of the object triggering the CHANGED event - this is
//              : NOT fully qualified.
// ----------------------------------------------------------------------------
onChanged:

   newData = param1
   
   begin case
      case ( atCtrl == "EDL_URL" )
         goSub edlURL_OnChanged
         
      case ( atCtrl == "CBO_METHOD" )
         goSub cboMethod_OnChanged
         
   end case
   
return

///////////////////////////////////////////////////////////////////////////////
// onChar subroutine
//
// Main CHAR event dispatch handler
//
// ----------------------------------------------------------------------------
// [i ]  atCtrl : Non-qualified (i.e. sans window ID) control ID that triggered
//              : the CHAR event
// [i]   param1 : virtCode
// [i]   param2 : scanCode
// [i]   param3 : ctrlKey
// [i]   param4 : shiftKey
// [i]   param5 : altKey
// ----------------------------------------------------------------------------
onChar:

   virtCode = param1
   scanCode = param2
   ctrlkey  = param3
   shiftkey = param4
   altkey   = param5
   
   begin case
      case ( atCtrl == "CBO_METHOD" )
         goSub cboMethod_OnChar
   end case
   
return

///////////////////////////////////////////////////////////////////////////////  
// onClick subroutine
//
// Main CLICK event dispatch handler
//
// ----------------------------------------------------------------------------
// [i]   atCtrl : ID of the object triggering the CLICK event - this is
//              : NOT fully qualified.
// ----------------------------------------------------------------------------
onClick:

   begin case
      case ( atCtrl == "BTN_TEST" )
         goSub btnTest_OnClick
   end case
   
return

///////////////////////////////////////////////////////////////////////////////  
// onEndDialog
//
// ENDDIALOG dispatch handler.  This assumes that the asyncID contains the 
// value used for the dispatch process.
//
// ----------------------------------------------------------------------------
// [i]   param1 : dialogID - name of the dialog that triggered the event
// [i]   param2 : dialogValue - data returned from the End_Dialog call
// [i]   param3 : asyncID - "cookie" value passed to the dialog when created
// ----------------------------------------------------------------------------
onEndDialog:

   dialogID    = param1
   dialogValue = param2
   asyncID     = param3
   
   begin case 
      case ( asyncID<HDL_RSPINFO_POS_ID$> == .pgd_UIParams->valueByName( "EndDialog AsyncID" ) )
         goSub onEndDialog_httpDownloadCallback
   
   end case
return

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// onEndDialog_httpDownloadCallback subroutine
//
// ENDDIALOG event handler for the RTI_HTTP_DOWNLOAD callback event.
//
// ----------------------------------------------------------------------------
// [i]   dialogID    : name of the dialog that triggered the event
// [i]   dialogValue : Response content (if not file based)
// [i]   asyncID     : Response header info
// ----------------------------------------------------------------------------
onEndDialog_httpDownloadCallback:

   objxArray =        @window : ".EDL_RESPONSE_ID"
   propArray =        "TEXT"
   dataArray =        asyncID<HDL_RSPINFO_POS_ID$>
   
   objxArray := @rm : @window : ".EDL_RESPONSE_STATUS_CODE"
   propArray := @rm : "TEXT"
   dataArray := @rm : asyncID<HDL_RSPINFO_POS_STATUSCODE$>
   
   objxArray := @rm : @window : ".EDL_RESPONSE_STATUS_TEXT"
   propArray := @rm : "TEXT"
   dataArray := @rm : asyncID<HDL_RSPINFO_POS_STATUSTEXT$>
   
   objxArray := @rm : @window : ".EDL_RESPONSE_CONTENTLEN"
   propArray := @rm : "TEXT"
   dataArray := @rm : asyncID<HDL_RSPINFO_POS_CONTENTLEN$>
   
   tmp = asyncID<HDL_RSPINFO_POS_HEADERS$>; swap @vm with \0D0A\ in tmp
   
   objxArray := @rm : @window : ".EDB_RESPONSE_HEADERS"
   propArray := @rm : "TEXT"
   dataArray := @rm : tmp
   
   tmp = asyncID<HDL_RSPINFO_POS_BYTESRECEIVED$>
   fileName = .edl_ResponseFile->text
   if bLen( fileName ) then
      // The response was downloaded into a file so just highlight this
      tmp := " (in " : fileName[-1,"B\"] : ")"
   end
   
   objxArray := @rm : @window : ".EDL_BYTES_RECEIVED"
   propArray := @rm : "TEXT"
   dataArray := @rm : tmp
   
   call set_Property_Only( objxArray, propArray, dataArray )
   
   call set_Property( @window : ".EBD_RESPONSE_CONTENT", "TEXT", dialogValue )
   
return

///////////////////////////////////////////////////////////////////////////////  
// onGotFocus subroutine
//
// Main GOTFOCUS event dispatch handler
//
// ----------------------------------------------------------------------------
// [i]   atCtrl : ID of the object triggering the CLICK event - this is
//              : NOT fully qualified.
// [i]   param1 : prevFocusID - ID of the last control on the window that 
//              : had an event handler defined for the GOTFOCUS event.
// ----------------------------------------------------------------------------
onGotFocus:

   prevFocusID = param1
   
   begin case
      case atCtrl == "CBO_METHOD"
         goSub cboMethod_OnGotFocus
   end case

return

///////////////////////////////////////////////////////////////////////////////
// onIConv subroutine
//
// ICONV dispatch handler.  Handles Iconv() processing for the following 
// branches:
//
//    CALLBACKPROC
//    
// ----------------------------------------------------------------------------
// [i] object : The literal string "ICONV"
// [i] method : "oValue" - The data to be validated
// [i] param1 : "branch" - the requested Iconv handler
// [o] param2 : "iValue" - The validated data
// ----------------------------------------------------------------------------
// Errors are returned via status() as per normal Iconv processing
// ----------------------------------------------------------------------------
onIconv:

   oValue = method
   branch = param1
   iValue = param2

   iValue   = ""
   status() = CONV_VALID$
   
   locate branch in "CALLBACKPROC" using "," setting pos then
      on pos goSub onIconv_CallBackProc
   end else
      status() = CONV_INVALID_CONV$
   end

return

///////////////////////////////////////////////////////////////////////////////
// onIconv_CallBackProc subroutine
//
// Verifies that a passed proc supports at least 2 args
//
// ----------------------------------------------------------------------------
// [i] oValue : The stored procedure name
// [o] iValue : The stored procedure name
// ----------------------------------------------------------------------------
// Errors are returned via status() as per normal Iconv processing
// ----------------------------------------------------------------------------
onIconv_CallBackProc:
   
   call set_Status( SETSTAT_OK$ )
   procInfo = rti_Get_Proc_Info( oValue )
   if get_Status( errorText ) then
      goSub setSPError;
   end else
      if ( procInfo<GPI_ARGCOUNT$> < 2 ) then
         errorText = "The Callback Procedure Name must support at least 2 parameters" 
         abort = TRUE$
      end
   end
   
   if abort then
      // We're about to display a validation error which will end 
      // up moving the focus - the problem is there may also be 
      // a SELPROPCHANGED event waiting, which we don't want to run
      // so we'll kill all pending events first
      call exec_Method( "SYSTEM", "FLUSH" )
      
      goSub errorMsg
      
      abort = FALSE$
      status() = CONV_INVALID_NOMSG$
      
   end
   
return

///////////////////////////////////////////////////////////////////////////////
// onOmniEvent subroutine
//
// Main OMNIEVENT event dispatch handler
//
// ----------------------------------------------------------------------------
// [i]   param1  : message
// [i]   param2  : Param 1
// [i]   param3  : Param 2
// [i]   param4  : Param 3
// [i]   param5  : Param 4
// [i]   param6  : Param 5
// [i]   param7  : Param 6
// ----------------------------------------------------------------------------  
onOmniEvent:

   transfer param1 to message
   transfer param2 to param1
   transfer param3 to param2
   transfer param4 to param3
   transfer param5 to param4
   transfer param6 to param5
   transfer param7 to param6
   
   begin case
      case ( atCtrl == "PGD_UIPARAMS" )
         goSub pgdUIParams_OnOmniEvent
   end case
   
   transfer param6  to param7
   transfer param5  to param6
   transfer param4  to param5
   transfer param3  to param4
   transfer param2  to param3
   transfer param1  to param2
   transfer message to param1
   
return

///////////////////////////////////////////////////////////////////////////////
// onOptions subroutine
//
// Main OPTIONS event dispatch handler
//
// ----------------------------------------------------------------------------
// [i]   atCtrl : ID of the object triggering the PROPCHANGED event
//              : this is not fully qualified.
// ----------------------------------------------------------------------------
onOptions:

   begin case
      case ( atCtrl == "EDL_RESPONSEFILE" )
         goSub edlResponseFile_OnOptions
   end case 
   
return

///////////////////////////////////////////////////////////////////////////////
// onPropChanged subroutine
//
// Main PROPCHANGED event dispatch handler
//
// ----------------------------------------------------------------------------
// [i]   atCtrl : ID of the object triggering the PROPCHANGED event
//              : this is not fully qualified.
// [i]   param1 : propName  - Name of the property that has changed
// [i]   param2 : propValue - Value of the property that has changed
// [i]   param3 : contextFlags  - Context the change was raised from
// ----------------------------------------------------------------------------
onPropChanged:

   propName     = param1
   propValue    = param2
   contextFlags = param3
   
   begin case
      case ( atCtrl == "PGD_UIPARAMS" )
         goSub pgdUIParams_OnPropChanged
   end case 
   
return

///////////////////////////////////////////////////////////////////////////////
// onPropOptions subroutine
//
// Main PROPOPTIONS event dispatch handler
//
// ----------------------------------------------------------------------------
// [i]   atCtrl : ID of the object triggering the PROPOPTIONS event - this 
//              : is not fully qualified.
// [i]   param1 : PropertyName - name of the property to display the options
//              : for 
// [i]   param2 : Current Property Value
// ----------------------------------------------------------------------------
onPropOptions:

   propName  = param1
   propValue = param2 
   
   begin case
      case ( atCtrl == "PGD_UIPARAMS" )
         goSub pgdUIParams_OnPropOptions
   end case 
   
return

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
#region CBO_METHOD
///////////////////////////////////////////////////////////////////////////////
// cboMethod_OnChanged subroutine
//
// CHANGED event handler for the CBO_METHOD control - update the enabled state 
// of BTN_TEST
//
// ----------------------------------------------------------------------------
cboMethod_OnChanged:
   goSub checkBtnTestEnabledState
return

///////////////////////////////////////////////////////////////////////////////
// cboMethod_OnChar subroutine
//
// CHAR event handler for the CBO_METHOD control - update the enabled state 
// of BTN_TEST
//
// ----------------------------------------------------------------------------
// [i]   virtCode
// [i]   scanCode
// [i]   ctrlKey
// [i]   shiftKey
// [i]   altKey
// ----------------------------------------------------------------------------
cboMethod_OnChar:
   goSub checkBtnTestEnabledState
return

///////////////////////////////////////////////////////////////////////////////
// cboMethod_OnGotFocus subroutine
//
// GOTFOCUS event handler for the CBO_METHOD control - Using the "default"
// handler to load the verb doesn't trigger the CHANGED event so we do it
// manually here.
//
// ----------------------------------------------------------------------------
// [i]   prevFocusID : ID of the last control on the window that 
//                   : had an event handler defined for the GOTFOCUS event.
// ----------------------------------------------------------------------------
cboMethod_OnGotFocus:
   goSub checkBtnTestEnabledState
return

///////////////////////////////////////////////////////////////////////////////
#endregion
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
#region BTN_TEST
///////////////////////////////////////////////////////////////////////////////
// btnTest_OnClick subroutine
//
// CLICK event handler for the BTN_TEST button: Extracts the list of arguments
// from the form and calls RTI_HTTP_DOWNLOAD to run the test.
//
// ----------------------------------------------------------------------------
btnTest_OnClick:

   useED        = .pgd_UIParams->valueByName( "Use EndDialog event" )
   asyncID      = ""
   callBackProc = ""
   callBackID   = ""
   
   if useED then
      asyncID = trim( .pgd_UIParams->valueByName( "EndDialog AsyncID" ) )
   end else
      callbackProc = trim( .pgd_UIParams->valueByName( "Procedure Name" ) )
      callBackID   = trim( .pgd_UIParams->valueByName( "Callback ID" ) )
   end
   
   objxArray =        @window : ".EDL_URL"
   propArray =        "TEXT"
   
   objxArray := @rm : @window : ".CBO_METHOD"
   propArray := @rm : "TEXT"
   
   objxArray := @rm : @window : ".EDL_TIMEOUT"
   propArray := @rm : "TEXT"
   
   objxArray := @rm : @window : ".EDL_PAYLOAD"
   propArray := @rm : "TEXT"
   
   objxArray := @rm : @window : ".EDL_USERNAME"
   propArray := @rm : "TEXT"
   
   objxArray := @rm : @window : ".EDL_PASSWORD"
   propArray := @rm : "TEXT"
   
   objxArray := @rm : @window : ".EDT_REQUESTHEADERS"
   propArray := @rm : "ARRAY"
   
   objxArray := @rm : @window : ".EDL_RESPONSEFILE"
   propArray := @rm : "TEXT"
   
   dataArray        = get_Property( objxArray, propArray )
   
   url              = dataArray[1,@rm,TRUE$]
   method           = dataArray[bCol2()+1,@rm,TRUE$]
   timeoutInfo      = dataArray[bCol2()+1,@rm,TRUE$]
   payload          = dataArray[bCol2()+1,@rm,TRUE$]
   userName         = trim( dataArray[bCol2()+1,@rm,TRUE$] )
   password         = dataArray[bCol2()+1,@rm,TRUE$]
   headers          = dataArray[bCol2()+1,@rm,TRUE$]
   responseFile     = dataArray[bCol2()+1,@rm,TRUE$]
   
   uiParams = ""
   
   if ( .pgd_UIParams->valueByName( "Use Parent Window" ) ) then
      uiParams<HDL_UIPARAM_POS_PARENTWIN$> = @window
   end
   uiParams<HDL_UIPARAM_POS_MODAL$>            = .pgd_UIParams->valueByName( "Modal" )
   uiParams<HDL_UIPARAM_POS_ENDDIALOGASYNCID$> = asyncID
   uiParams<HDL_UIPARAM_POS_CALLBACKPROC$>     = callbackProc
   uiParams<HDL_UIPARAM_POS_CALLBACKID$>       = callBackID
   uiParams<HDL_UIPARAM_POS_DOWNLOADTEXT$>     = .pgd_UIParams->valueByName( "Loading Text" )
   uiParams<HDL_UIPARAM_POS_SYNCPROGRESS$>     = .pgd_UIParams->valueByName( "Sync Taskbar" )
   
   if bLen( userName ) then
      credentials = userName : @fm : password
   end else
      credentials = ""
   end
   
   tmp = headers
   convert " ":@fm:@vm to "" in tmp
   if bLen( tmp ) else
      headers = ""
   end
   
   call set_Status( SETSTAT_OK$ )
   call rti_HTTP_Download( uiParams, url, method, payload, credentials, |
                           headers, timeoutInfo, responseFile )
   if get_Status( errorText ) then
      goSub setSPError
   end

return

///////////////////////////////////////////////////////////////////////////////
#endregion
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
#region EDL_RESPONSEFILE
///////////////////////////////////////////////////////////////////////////////
// edlResponseFile_OnOptions subroutine
//
// OPTIONS event handler for the EDL_RESPONSEFILE button - displays the 
// standard File Open dialog for the user to choose a file to write the
// content to.
//
// ----------------------------------------------------------------------------
edlResponseFile_OnOptions:

   cfFlags  = bitOr( OFN_HIDEREADONLY$, OFN_NOCHANGEDIR$ )
   
   fileName = @object->text
   
   if index( fileName, "\", 1 ) then
      defName  = fileName[-1,"B\"]
      filePath = fileName[1,col1()-1]
      if index( defName, ".", 1 ) else
         if ( $fileSystem->dirExists( fileName ) ) then
            defName  = "ResponseContent.txt"
            filePath = fileName
         end
      end
   end else
      filePath = drive()
      defName  = fileName
   end
      
   cfOptions = ""
   cfOptions<CHFILE_POS_MODE$>         = CHFILE_MODE_SAVEAS$
   cfOptions<CHFILE_POS_FILTERSTRING$> = "All Files (*.*)/*.*/"
   cfOptions<CHFILE_POS_FILTERINDEX$>  = 1
   cfOptions<CHFILE_POS_DFLTNAME$>     = defName
   cfOptions<CHFILE_POS_FLAGS$>        = cfFlags
   cfOptions<CHFILE_POS_INITDIR$>      = filePath
   cfOptions<CHFILE_POS_TITLE$>        = "Specify Response File"
   
   fileName = $fileSystem->chooseFile( @window, cfOptions )
   if bLen( fileName ) then
      @object->text = fileName
   end

return

///////////////////////////////////////////////////////////////////////////////
#endregion
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
#region EDL_URL
///////////////////////////////////////////////////////////////////////////////
// edlURL_OnChanged subroutine
//
// CHANGED event handler for the EDL_URL control - update the enabled state 
// of BTN_TEST
//
// ----------------------------------------------------------------------------
edlURL_OnChanged:
   goSub checkBtnTestEnabledState
return

///////////////////////////////////////////////////////////////////////////////
#endregion
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
#region PDG_UIPARAMS
///////////////////////////////////////////////////////////////////////////////
// pgdUIParams_OnOmniEvent subroutine
//
// PGD_UIPARAMS OMNIEVENT handler
//
// ----------------------------------------------------------------------------
// [i]   message : Identifies the OMNIEVENT message
// [i]   param1  : Polymorphic message parameters
// ...     ...   :          ... 
// [i]   param8  : Polymorphic message parameters
// ----------------------------------------------------------------------------
pgdUIParams_OnOmniEvent:

   begin case
      case ( message == "PGO_ENDDIALOG" )
         goSub pgdUIParams_OnOmniEvent_PGO_EndDialog
         
   end case
   
return

///////////////////////////////////////////////////////////////////////////////
// pgdUIParams_OnOmniEvent_PGO_EndDialog subroutine
//
// OMNIEVENT PGO_ENDDIALOG handler - updates the property grid with the results
// of a PGO non-modal dialog
//
// ----------------------------------------------------------------------------
// [i]   param1 : Property name
// [1]   param2 : New property value
// ----------------------------------------------------------------------------
pgdUIParams_OnOmniEvent_PGO_EndDialog:

   @object->valueByName( param1, param2 )
   goSub checkBtnTestEnabledState
   
return

///////////////////////////////////////////////////////////////////////////////
// pgdUIParams_onPropChanged subroutine
//
// PROPCHANGED event handler for the PGD_UIPARAMS property grid.
//
// ----------------------------------------------------------------------------
// [i]   propName     - Name of the property that has changed
// [i]   propValue    - Value of the property that has changed
// [i]   contextFlags - Context the change was raised from
// ----------------------------------------------------------------------------
pgdUIParams_onPropChanged:

   begin case
      case ( propName == "Use EndDialog event" )
         // If this is enabled then:
         //
         //    EndDialog AsyncID should be enabled
         //    Procedure Name CallBack ID should be disabled
         //
         // else
         //    EndDialog AsyncID should be disabled
         //    Procedure Name CallBack ID should be enabled
         
         @object{"EndDialog AsyncID"}->enabled = propValue
         @object{"Procedure Name"}->enabled    = not( propValue )
         @object{"CallBack ID"}->enabled       = not( propValue )
         
   end case
   
   goSub checkBtnTestEnabledState
   
return
      
///////////////////////////////////////////////////////////////////////////////
// pgdUIParams_OnPropOptions subroutine
//
// PROPOPTIONS event handler for the PDG_UIPARAMS property grid control
//
// ----------------------------------------------------------------------------
// [i]   propName  : Name of the property to display the options
// [i]   propValue : Current Property Value
// ----------------------------------------------------------------------------
pgdUIParams_OnPropOptions:

   begin case
      case propName == "EndDialog AsyncID"
         // Display the RTI_IDE_PGO_TEXTLINE dialog 
         goSub pgdUIParams_OnPropOptions_Display_TextLine_Dlg
      case propName == "Procedure Name"
         // Display the RTI_IDE_OPEN dialog with STPROCEXES loaded
          goSub pgdUIParams_OnPropOptions_Display_EntOpen_Dlg
      case propName == "Callback ID"
         // Display the RTI_IDE_PGO_TEXTLINE dialog 
         goSub pgdUIParams_OnPropOptions_Display_TextLine_Dlg
      case propName == "Loading Text"
         // Display the RTI_IDE_PGO_TEXTLINE dialog 
         goSub pgdUIParams_OnPropOptions_Display_TextLine_Dlg
   end case

return

///////////////////////////////////////////////////////////////////////////////
// pgdUIParams_OnPropOptions_Display_TextLine_Dlg subroutine
//
// Display the RTI_IDE_PGO_TEXTLINE dialog to allow the user to enter a larger 
// display a larger amount of text.
// ----------------------------------------------------------------------------
// [i]   propName  : Name of the property to display the options
// [i]   propValue : Current Property Value
// ----------------------------------------------------------------------------
pgdUIParams_OnPropOptions_Display_TextLine_Dlg:

   dlgParam = ""
   dlgParam<PGOTEXTLINE_CREATEPARAM_PROPGRID$> = object
   dlgParam<PGOTEXTLINE_CREATEPARAM_PROPNAME$> = propName
   dlgParam<PGOTEXTLINE_CREATEPARAM_TEXT$>     = propValue
   dlgParam<PGOTEXTLINE_CREATEPARAM_CACHEID$>  = "RTI_HTTP_DOWNLOAD_TEST"
   
   call start_Window( "RTI_IDE_PGO_TEXTLINE", @window, dlgParam )
   
return

///////////////////////////////////////////////////////////////////////////////
// pgdUIParams_OnPropOptions_Display_EntOpen_Dlg subroutine
//
// Display the RTI_IDE_OPEN dialog to allow the user to select an STPROCEXE
// ----------------------------------------------------------------------------
// [i]   propName  : Name of the property to display the options
// [i]   propValue : Current Property Value
// ----------------------------------------------------------------------------
pgdUIParams_OnPropOptions_Display_EntOpen_Dlg:

   dlgID   = rti_IDE_CFG( "GETDIALOG", IDE_CFG_GETDLG_T_OPENENT$ )
   
   itemSize = @object->screenSizeByName( propName )

   xPos = itemSize<1> + itemSize<3>
   yPos = itemSize<2> + itemSize<4>

   dlgParam = ""
   dlgParam<IDE_OPN_CREATEPARAM_TYPEID$>       = "STPROCEXE"
   dlgParam<IDE_OPN_CREATEPARAM_ENTITYID$>     = propValue
   dlgParam<IDE_OPN_CREATEPARAM_MODE$>         = FALSE$
   dlgParam<IDE_OPN_CREATEPARAM_XPOS$>         = xPos : @vm : TRUE$  : @vm : TRUE$
   dlgParam<IDE_OPN_CREATEPARAM_YPOS$>         = yPos : @vm : FALSE$ : @vm : TRUE$
   dlgParam<IDE_OPN_CREATEPARAM_NONSEL$>       = TRUE$
   dlgParam<IDE_OPN_CREATEPARAM_TITLE$>        = propName
   
   propValue = dialog_Box( dlgID, @window, dlgParam )
   if bLen( propValue ) then
      // Verify that it can take at least 2 args for the callback from the 
      // download form
      
      propValue = field( propValue, "*", 4, 9999 )
      
      call set_Status( SETSTAT_OK$ )
      procInfo = rti_Get_Proc_Info( propValue )
      if get_Status( errorText ) then
         goSub setSPError
         return
      end
      
      if ( procInfo<GPI_ARGCOUNT$> < 2 ) then
         errorText = "The Callback Procedure Name must support at least 2 parameters" 
         abort     = TRUE$
         return
      end
      
      @object->valueByName( propName, propValue )
      goSub checkBtnTestEnabledState
      
   end
   
return

///////////////////////////////////////////////////////////////////////////////
#endregion
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// checkBtnTestEnabledState subroutine
//
// This subroutine scans the Request parameters and enables the BTN_TEST 
// button if there is enough information to conduct a RTI_HTTP_DOWNLOAD test.
//
// We have to meet the following criteria:
//
//    1) We have a URL
//    2) We have a method (verb)
//    3) We have one of the following:
//          i)  An End Dialog AsyncID, or
//          ii) A CallbackProcID
//
// ----------------------------------------------------------------------------
checkBtnTestEnabledState:
   
   enableTest = TRUE$
   useED      = .pgd_UIParams->valueByName( "Use EndDialog event" )
   if useED then
      asyncID = trim( .pgd_UIParams->valueByName( "EndDialog AsyncID" ) )
      if bLen( asyncID ) else
         enableTest = FALSE$
      end
   end else
      callbackProc = trim( .pgd_UIParams->valueByName( "Procedure Name" ) )
      if bLen( callbackProc ) else
         enableTest = FALSE$
      end
   end
   
   if enableTest then
      if bLen( trim( .edl_URL->text ) ) then
         if bLen( trim( .cbo_Method->text ) ) else
            enableTest = FALSE$
         end
      end else
         enableTest = FALSE$
      end
   end
   
   .btn_Test->enabled = enableTest
   
return

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// errorMsg subroutine
//
// Displays a simple error message
//
// ----------------------------------------------------------------------------
// [i]   errorText    : Text to display in the message
// [i]   errorCaption : Caption for the message
// ----------------------------------------------------------------------------
errorMsg:

   if assigned( errorCaption ) else errorCaption = ""
   if bLen( errorCaption ) else
      errorCaption = @@window->text
   end

   msgArray     = errorText
   msgArray<4>  = "!"
   msgArray<6>  = -2
   msgArray<7>  = -2
   msgArray<8>  = "C"
   msgArray<12> = errorCaption

   call msg( @window, msgArray )

return

///////////////////////////////////////////////////////////////////////////////
// setSPError subroutine
//
// Translates an SSP status error array into a "text version" from REVERROR.DAT
//
// ----------------------------------------------------------------------------
// [i,o] errorText : SSP status error to convert.  Returns the "text" version 
// ----------------------------------------------------------------------------
setSPError:
     errorText = rti_ErrorText( "SP", errorText )
     abort = TRUE$
return

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

