############################################################################
# Copyright (C) 1982-2005 ESL Syndetic Limited #
# All Rights Reserved. #
# #
# NOTICE #
# PROPRIETARY AND CONFIDENTIAL #
# #
# This computer program is and contains trade secret and confidential and #
# proprietary information of ESL Syndetic Limited. All use, disclosure, #
# and/or reproduction not specifically authorized in writing by #
# ESL Syndetic Limited is prohibited. This program may also be protected #
# under the copyright and trade secrets laws of countries other than the #
# U.S.A. #
# #
# #
############################################################################
#
application TestApp
include "accel.inc"
include "APPTEST.INC"
boolean variable DidOKCUA
#
# Variable Definitions
#
string FileNameV
string FileSpecV ## The filespec entered... D:\EASEL\TEST\filename.exe
string DirNameV
string RunParamV
string SaveNameV is "session.txt"
boolean LineModeV is true
string ThisLine
integer LineColor
# API Structure and definitions for Browse function
# generic strings:
#
structure OS_256_STR is
string Str using string size 256
end structure
# The Open/Save data...
structure OS_OPEN_STR is
integer LStructSize
integer HwndOwner
integer HInstance
integer LpstrFilter
integer LpstrCustomFilter
integer NMaxCustFilter
integer NFilterIndex
integer LpstrFile
integer NMaxFile
integer LpstrFileTitle
integer NMaxFileTitle
integer LpstrInitialDir
integer LpstrTitle
integer Flags
integer NFileOffset using integer size 2
integer NFileExtension using integer size 2
integer LpstrDefExt
integer LCustData
integer LpfnHook
integer LpTemplateName
end structure
# file type filters...
structure OS_AllFilesFilter_STR is
string Filter1 using string size 20 # includes one null
string Filter2 using string size 7 # includes two nulls
end structure
structure OS_SaveFilesFilter_STR is
string Filter1 using string size 18 # includes one null
string Filter2 using string size 6 # includes one nulls
string Filter3 using string size 16 # includes one null
string Filter4 using string size 5 # includes two nulls
end structure
# structure instances...
structure OS_OPEN_STR OS_OPEN_Data
structure OS_AllFilesFilter_STR OS_Filter
structure OS_SaveFilesFilter_STR OS_SaveFilter
structure OS_256_STR OS_FileName
structure OS_256_STR OS_StrInitialDir
structure OS_256_STR OS_StrTitle
structure OS_256_STR OS_StrFileTitle # name w/out dir
# Windows API
function OS_GetOpenFileName(structure OS_OPEN_STR: OpenFileName)
returns boolean
external name "GetOpenFileNameA" library "comdlg32"
function OS_GetSaveFileName(structure OS_OPEN_STR: OpenFileName)
returns boolean
external name "GetSaveFileNameA" library "comdlg32"
#
# Local subroutines
#
subroutine SetupSelectDB(
string : FileSpecV,
string : DirNameV )
subroutine QuerySelectDB(
string : FileSpecV,
string : FileNameV,
string : DirNameV )
subroutine ProcessSelectDB( boolean : DidOKCUA )
subroutine SetupRunParamDB(
string : RunParamV )
subroutine QueryRunParamDB(
string : RunParamV )
subroutine ProcessRunParamDB( boolean : DidOKCUA )
subroutine ScrollWin ()
subroutine ColorLine (integer: ForeGround )
#
# Subroutine Definition(s)
#
subroutine SetupRunParamDB( string : RunParamV ) is
change RunParamEF in RunParamDB text to RunParamV
subroutine ProcessRunParamDB( boolean : DidOKCUA ) is
begin guarded
response to start
make RunParamDB visible
response to OK in RunParamDB
copy true to DidOKCUA
make RunParamDB invisible
leave block
response to Cancel in RunParamDB
copy false to DidOKCUA
make RunParamDB invisible
leave block
end
subroutine QueryRunParamDB( string : RunParamV ) is
copy text of RunParamEF in RunParamDB to RunParamV
subroutine SetupSelectDB( string : FileNameV, string : DirNameV ) is
string Directory
copy "Directory is: " DirNameV to Directory
change FileSpecEF in SelectDB text to FileNameV
change CurrDirST in SelectDB text to Directory
subroutine BrowseForExecuteable( boolean : DidOKCUA,
string : File_Name,
string : Path) is
integer Error_Level
copy "Select Local Application" to OS_StrTitle.Str
copy File_Name to OS_FileName.Str
copy size of OS_OPEN_STR to OS_OPEN_Data.LStructSize
copy handle of PrimaryWindow to OS_OPEN_Data.HwndOwner
copy "Executables (*.exe)" to OS_Filter.Filter1
copy "*.exe" to OS_Filter.Filter2
copy handle of OS_Filter to OS_OPEN_Data.LpstrFilter
copy 1 to OS_OPEN_Data.NFilterIndex
copy size of OS_256_STR to OS_OPEN_Data.NMaxFile
copy handle of OS_FileName to OS_OPEN_Data.LpstrFile
copy size of OS_256_STR to OS_OPEN_Data.NMaxFileTitle
copy handle of OS_StrFileTitle to OS_OPEN_Data.LpstrFileTitle
copy handle of OS_StrInitialDir to OS_OPEN_Data.LpstrInitialDir
copy handle of OS_StrTitle to OS_OPEN_Data.LpstrTitle
copy (1*16*16*16) to OS_OPEN_Data.Flags # file must exist
copy OS_GetOpenFileName(OS_OPEN_Data) to Error_Level
#If we got a file name, return it to the caller
if (Error_Level != 0) then
extract from OS_FileName.Str
take by OS_OPEN_Data.NFileOffset Path
take to last File_Name
copy true to DidOKCUA
else
copy false to DidOKCUA
end if
subroutine SaveSessionToFile() is
integer Error_Level
copy "Save Session Data as..." to OS_StrTitle.Str
copy SaveNameV to OS_FileName.Str
copy size of OS_OPEN_STR to OS_OPEN_Data.LStructSize
copy handle of PrimaryWindow to OS_OPEN_Data.HwndOwner
copy "Text file (*.txt)" to OS_SaveFilter.Filter1
copy "*.txt" to OS_SaveFilter.Filter2
copy "All Files (*.*)" to OS_SaveFilter.Filter3
copy "*.*" to OS_SaveFilter.Filter4
copy handle of OS_SaveFilter to OS_OPEN_Data.LpstrFilter
copy 1 to OS_OPEN_Data.NFilterIndex
copy size of OS_256_STR to OS_OPEN_Data.NMaxFile
copy handle of OS_FileName to OS_OPEN_Data.LpstrFile
copy size of OS_256_STR to OS_OPEN_Data.NMaxFileTitle
copy handle of OS_StrFileTitle to OS_OPEN_Data.LpstrFileTitle
copy handle of OS_StrInitialDir to OS_OPEN_Data.LpstrInitialDir
copy handle of OS_StrTitle to OS_OPEN_Data.LpstrTitle
copy 2 to OS_OPEN_Data.Flags # confirm before overwrite
copy OS_GetSaveFileName(OS_OPEN_Data) to Error_Level
#If we got a file name, return it to the caller
if (Error_Level != 0) then
extract from OS_FileName.Str
skip by OS_OPEN_Data.NFileOffset
take to last SaveNameV
write destructive PrimaryWindow to file OS_FileName.Str
end if
subroutine ProcessSelectDB( boolean : DidOKCUA ) is
string FileName
Directory
begin guarded
response to start
make SelectDB visible
response to OK in SelectDB
copy true to DidOKCUA
make SelectDB invisible
leave block
response to Cancel in SelectDB
copy false to DidOKCUA
make SelectDB invisible
leave block
response to ParamPB in SelectDB
make RunParamDB permanent
call SetupRunParamDB(RunParamV)
call ProcessRunParamDB( DidOKCUA )
if (DidOKCUA) then
call QueryRunParamDB(RunParamV)
end if
make RunParamDB temporary
response to BrowsePB in SelectDB
call BrowseForExecuteable( DidOKCUA,
FileName,
Directory)
if (DidOKCUA) then
call SetupSelectDB( FileName, Directory )
end if
end
subroutine QuerySelectDB( string : FileSpecV, string : FileNameV, string : DirNameV ) is
copy text of FileSpecEF in SelectDB to FileNameV
extract from (text of CurrDirST in SelectDB)
skip by "Directory is: "
take to last DirNameV
copy DirNameV FileNameV to FileSpecV
#
# Response Definition(s)
#
subroutine ScrollWin () is
if (ycursor of PrimaryWindow >= (window yposition of PrimaryWindow + window ysize of PrimaryWindow)) then
change PrimaryWindow window position to column 1 line (ycursor of PrimaryWindow - window ysize of PrimaryWindow + 1)
end if
subroutine ColorLine (integer: ForeGround ) is
make PrimaryWindow segment
column 1 line (ycursor of PrimaryWindow - 1)
thru
column right of PrimaryWindow line (ycursor of PrimaryWindow - 1)
foreground color ForeGround
response to start
turn trace off
copy 20 to LineColor
add to PrimaryWindow
insert "Comments displayed in this color, input not yet sent in grey.\n"
call ColorLine (LineColor)
add to PrimaryWindow
insert "Input sent to local is black, and output from local is blue.\n"
call ColorLine (LineColor)
response to item SelectPD from PrimaryWindowABCUA
make SelectDB permanent
call SetupSelectDB( FileNameV, DirNameV )
call ProcessSelectDB( DidOKCUA )
if ( DidOKCUA ) then
call QuerySelectDB( FileSpecV, FileNameV, DirNameV )
add to PrimaryWindow
insert "\nApplication: \"" FileNameV "\" selected.\n"
call ScrollWin()
copy 20 to LineColor
call ColorLine (LineColor)
enable item RunPD in PrimaryWindow
end if
make SelectDB temporary
response to item RunPD from PrimaryWindowABCUA
if (RunParamV = "") then
start local TestApp FileSpecV
else
start local TestApp FileSpecV RunParamV
end if
if (errorlevel > 0) then
add to PrimaryWindow
insert "\nApplication: \"" FileSpecV "\" failed to start succesfully!\n"
call ScrollWin ( )
copy 1 to LineColor
call ColorLine (LineColor)
disable item StopPD in PrimaryWindow
disable item RunPD in PrimaryWindow
enable item SelectPD in PrimaryWindow
make PrimaryWindow cursor invisible
else
copy 20 to LineColor
add to PrimaryWindow
insert "\nApplication: \"" FileSpecV "\" started OK. Enter lines to send at cursor.\n"
call ColorLine (LineColor)
call ScrollWin ( )
enable item StopPD in PrimaryWindow
disable item RunPD in PrimaryWindow
disable item SelectPD in PrimaryWindow
action LineEntry
end if
response to item StopPD
stop TestApp
add to PrimaryWindow
insert "\nApplication: \"" FileSpecV "\" stopped.\n"
call ScrollWin ( )
copy 20 to LineColor
call ColorLine (LineColor)
disable item RunPD in PrimaryWindow
disable item StopPD in PrimaryWindow
enable item SelectPD in PrimaryWindow
make PrimaryWindow cursor invisible
interrupt response to item SaveSesPD from PrimaryWindowABCUA
call SaveSessionToFile()
interrupt response to item Clear from PrimaryWindowABCUA
clear PrimaryWindow
change PrimaryWindow window position to 1 1
response to item Reset from PrimaryWindowABCUA
clear PrimaryWindow
change PrimaryWindow window position to 1 1
stop all
disable item RunPD in PrimaryWindow
disable item StopPD in PrimaryWindow
enable item SelectPD in PrimaryWindow
copy "" to FileSpecV
copy "" to FileNameV
copy "" to DirNameV
copy "session.txt" to SaveNameV
response to item Exit
exit
item class EntryMode is LineModePD CharModePD
interrupt response to item EntryMode
uncheck item EntryMode in PrimaryWindow
check item object in PrimaryWindow
if ( object = "LineModePD" ) then
copy true to LineModeV
else
copy false to LineModeV
end if
item class TraceMode is TraceOnPD TraceOffPD
interrupt response to item TraceMode
uncheck item TraceMode in PrimaryWindow
check item object in PrimaryWindow
if ( object = "TraceOnPD" ) then
turn trace on
else
turn trace off
end if
action LineEntry is
begin LineEntryBlock
response to start
make PrimaryWindow cursor visible
response to char "\e" from keyboard
begin guarded
response to char "\e" from keyboard
make PrimaryWindow cursor invisible
leave block LineEntryBlock
response to char from keyboard
leave block
end
response to line from keyboard
add to PrimaryWindow
insert "\n"
copy 8 to LineColor
call ColorLine (LineColor)
call ScrollWin ( )
if (LineModeV) then
send (textual line (ycursor of PrimaryWindow - 1) from PrimaryWindow ) "\n" to TestApp
else
send "\n" to TestApp
end if
response to char from keyboard
add to PrimaryWindow
insert input
if not(LineModeV) then
send input to TestApp
make PrimaryWindow segment
column 1 line ycursor of PrimaryWindow
thru
column right of PrimaryWindow line ycursor of PrimaryWindow
foreground color 8
end if
response to line from TestApp
if not(LineModeV) then
add to PrimaryWindow
insert "\n"
else
add to PrimaryWindow
insert ThisLine "\n"
copy "" to ThisLine
end if
call ScrollWin ( )
copy 4 to LineColor
call ColorLine (LineColor)
response to char from TestApp
if not(LineModeV) then
add to PrimaryWindow
insert input
make PrimaryWindow segment
column 1 line ycursor of PrimaryWindow
thru
column right of PrimaryWindow line ycursor of PrimaryWindow
foreground color 4
else
append input to ThisLine
end if
response to termination
make PrimaryWindow cursor invisible
end LineEntryBlock