Files
open-insight/SYSPROG/STPROC/RTI_EXAMPLE_LOGIN_TEMPLATE.txt
2024-03-25 15:17:34 -07:00

264 lines
8.8 KiB
Plaintext

compile function RTI_Example_Login_Template( object, method, param1, param2, param3, param4, param5, param6, param7, param8 )
/*
** Copyright (C) 2012-2019 Revelation Software Inc. All Rights Reserved **
Author : Mr C
Date : September 2019
Purpose : Commuter module for the RTI_EXAMPLE_LOGIN_TEMPLATE form
Comments
========
Amended Date Reason
======= ==== ======
*/
#pragma precomp event_precomp
declare function get_Property, set_Property, utility, retStack, rti_ErrorText
declare function ps_Get_Property, rti_Res2Str, msg, exec_Method
$insert rti_SSP_Equates
$insert logical
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 = ""
if assigned( param7 ) else param7 = ""
if assigned( param8 ) else param8 = ""
errorText = ""
abort = FALSE$
retVal = ""
atCtrl = field( object, ".", 2, 999 )
if bLen( method ) then
locate method in "CLICK,OMNIEVENT" using "," setting pos then
on pos goSub onClick,onOmniEvent
end
end
if abort then
if bLen( errorText ) then
goSub errorMsg
end
end
return retVal
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// 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 == "LOGIN_BUTTON" )
goSub loginButton_OnClick
end case
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 == "INITLOGIN" )
goSub initLogin_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
///////////////////////////////////////////////////////////////////////////////
#region initLogin
///////////////////////////////////////////////////////////////////////////////
// initLogin_OnOmniEvent subroutine
//
// OMNIEVENT event handler for the INITLOGIN control
//
// INITLOGIN is a simple static control that responds to an "INITLOGIN"
// OMNIEVENT message - this is called from the "hosting" PS_OPENAPP form
// this form is used as a template
//
// ----------------------------------------------------------------------------
// [i] message : Identifies the message to process
// [i] param1 : Message dependant parameter
// [i] param2 : Message dependant parameter
// [i] param3 : Message dependant parameter
// [i] param4 : Message dependant parameter
// [i] param5 : Message dependant parameter
// [i] param6 : Message dependant parameter
// ----------------------------------------------------------------------------
initLogin_OnOmniEvent:
locate message in "INITLOGIN" using "," setting pos then
on pos goSub initLogin_OnOmniEvent_initLogin
end
return
///////////////////////////////////////////////////////////////////////////////
// initLogin_OnOmniEvent_initLogin subroutine
//
// INITLOGIN OMNIEVENT message handler for the INITLOGIN control
//
// 1) Check that we have an EXAMPLES application and select it
// 2) Force it into run mode
//
// ----------------------------------------------------------------------------
// [i] param1 : CreateParam. Contains the original parameters as passed to
// : the "real" login form (PS_OPENAPP)
// :
// : <1> AppID to preselect
// : <2> UserID to preselect
// : <3> Primary boot flag
// : <4> Template ID to use
// ----------------------------------------------------------------------------
initLogin_OnOmniEvent_initLogin:
createParam = param1
// Check to see that this system supports the EXAMPLES app
appIDs = .lst_AppIDs->list
locate "EXAMPLES" in appIDs using @fm setting pos else
errorText = "The EXAMPLES app cannot be found in this system"
goSub errorMsg; errorText = ""
call send_Event( @window, "CLOSE" )
return
end
// Changing the appID and checking the "RunApp" checkbox will change
// the window title so something like "Open Application" or "Run
// Application", so cache it and reset it after the changes.
winText = @@window->text
// Force the examples app to load
.lst_appIDs->changeText( "EXAMPLES" )
// If the EXAMPLES app can be "Run" then the CHK_RUNAPP checkbox will be
// enabled - in this case we'll ensure it's checked.
if ( .chk_RunApp->enabled ) then
.chk_RunApp->setChecked( TRUE$ )
end
// Restore the title from the template
@@window->text = winText
return
///////////////////////////////////////////////////////////////////////////////
#endregion initLogin
///////////////////////////////////////////////////////////////////////////////
#region loginButton
///////////////////////////////////////////////////////////////////////////////
// loginButton_OnClick subroutine
//
// CLICK event handler for the LOGIN_BUTTON control.
//
// 1) Transfer the username and password entered by the user to the "real"
// controls (EDL_USERNAME) and (EDL_PASSWORD)
// 2) Execute a Click method on the "real" OK button (BTK_OK) to log into
// the application.
//
// ----------------------------------------------------------------------------
loginButton_OnClick:
// Transfer the credentials
.edl_UserName->text = .userName->text
.edl_Password->text = .password->text
// Click the OK button to authenticate
.btn_ok->click( "" )
return
///////////////////////////////////////////////////////////////////////////////
#endregion loginButton
///////////////////////////////////////////////////////////////////////////////
#region errorHandlers
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// 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
///////////////////////////////////////////////////////////////////////////////
#endregion errorHandlers
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////