home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
odrtime.zip
/
OPENPACK
/
EPM
/
SCREDREC.E
< prev
next >
Wrap
Text File
|
1995-11-22
|
46KB
|
1,264 lines
---- commands used by Script Editor and Recorder (SCREDREC)
#define SUPPORT_USERS_GUIDE 1
#define SUPPORT_TECHREF 1
compile if not defined(NLS_LANGUAGE)
const NLS_LANGUAGE = 'English'
compile endif
compile if not defined(WANT_DYNAMIC_PROMPTS)
WANT_DYNAMIC_PROMPTS = 1
compile endif
include NLS_LANGUAGE'.e'
include 'stdconst.e'
; HP_* etc ....
include 'menuhelp.h'
include 'scredhlp.h'
const
NULL = \0 || \0 || \0 || \0
DO_AE_INIT = 1
;; log file disabled ...
LOG_FILE_NAME = ''
;; LOG_FILE_NAME = 'scredrec.log'
;; OSA_DEFAULT_LANGUAGE = 'OREXX'
const
OSA_off = 0
OSA_on = 1
OSA_started = -1
OSA_dying = -2
OSA_suspended = -6
;; constants, msg #s etc...
include 'scredmsg.h'
defc scredrec_start =
arg_str = arg(1)
fn = ''
options = ''
while arg_str<>'' do
parse value arg_str with param arg_str
if pos(leftstr(param,1),"/-")>0 then -- option
opt=substr(param,2)
if opt=='s' or opt=="S" then -- stable bar
call make_stable_bar()
else
options = options param
endif
elseif fn == '' then
fn = param
endif
endwhile
if fn <>'' then
.filename=fn' ...'
;; sayerror 'wait for loading the file ...'
'postme edit' fn
endif
;; call set_OSA_status()
return
definit
universal OSA_bar__msg
universal OSA_Compile_Menu__msg
universal OSA_Install_Menu__msg
universal OSA_Dictionary_Menu__msg
universal OSA_Play_Menu__msg
universal OSA_Stop_Menu__msg
universal OSA_Record_Menu__msg
universal OSA_Lang_Menu__msg
universal OSA_synt_chk_Menu__msg
universal OSA_Show_Results_Menu__msg
universal OSA_barp__msg
universal OSA_Compile_menuP__msg
universal OSA_Dictionary_menuP__msg
universal OSA_Play_menuP__msg
universal OSA_Stop_menuP__msg
universal OSA_Record_menuP__msg
universal OSA_Lang_menuP__msg
universal OSA_synt_chk_menuP__msg
universal OSA_Show_Results_menuP__msg
universal Scred_file_erase_warning
universal Scred_file_erase_warning2
universal Script_Editor_EPM_title
universal Default_Script_Comp_name
universal Scred_Play_toolbar_title
universal Scred_Stop_toolbar_title
universal Scred_Record_toolbar_title
universal Scred_synt_chk_toolbar_title
universal Scred_Script_lang_toolbar_title_head
universal Scred_Recording_statusline_title
universal Scred_Recording_suspended_statusline_title
universal activeucmenu, toolbar_loaded
universal OSA_language
--- global vars to control playing/recording;
--- in the future, OSA_record will have 4 possible values,
--- off, on, started, and dying;
--- meanwhile, both are boolean
universal OSA_play, OSA_record, OSA_synt_check
-- this says that the toolbar stays stable, and the Recording/playing info
-- is shown in the status line ...
universal stable_bar
universal source_version, compiled_source_version, temp_source_version
universal tmp_fn, source_only
universal scredrec_modified
universal scredrec_last_modified
scredrec_modified = 0
scredrec_last_modified = 0
source_only = OSA_on
tmp_fn = ''
source_version = 0
compiled_source_version = 0
temp_source_version = 0
stable_bar = OSA_off
OSA_play = OSA_off
OSA_record = OSA_off
OSA_synt_check = OSA_off
;;
;; add SCREDREC help file ...
findfile scredrec_help, 'scredrec.hlp', 'EPMPATH'
if rc then
sayerror scred_NLS_string('Scred_EPM_file_not_found_msg')
endif
'compiler_help_add' scredrec_help
;; get the NLS strings ...
OSA_bar__msg = TILDE_CHAR||scred_NLS_string('OSA_bar__msg')
OSA_Compile_Menu__msg = scred_NLS_string('OSA_Compile_Menu__msg')
OSA_Install_Menu__msg = scred_NLS_string('OSA_Install_Menu__msg')
OSA_Dictionary_Menu__msg = scred_NLS_string('OSA_Dictionary_Menu__msg')
OSA_Play_Menu__msg = scred_NLS_string('OSA_Play_Menu__msg')
OSA_Stop_Menu__msg = scred_NLS_string('OSA_Stop_Menu__msg')
OSA_Record_Menu__msg = scred_NLS_string('OSA_Record_Menu__msg')
OSA_Lang_Menu__msg = scred_NLS_string('OSA_Lang_Menu__msg')
OSA_synt_chk_Menu__msg = scred_NLS_string('OSA_synt_chk_Menu__msg')
OSA_Show_Results_Menu__msg = scred_NLS_string('OSA_Show_Results_Menu__msg')
;; and add EPM special chars for the menubar help messages ...
OSA_barp__msg = \1||scred_NLS_string('OSA_barp__msg')
OSA_Compile_menuP__msg = \1||scred_NLS_string('OSA_Compile_menuP__msg')
OSA_Dictionary_menuP__msg = \1||scred_NLS_string('OSA_Dictionary_menuP__msg')
OSA_Play_menuP__msg = \1||scred_NLS_string('OSA_Play_menuP__msg')
OSA_Stop_menuP__msg = \1||scred_NLS_string('OSA_Stop_menuP__msg')
OSA_Record_menuP__msg = \1||scred_NLS_string('OSA_Record_menuP__msg')
OSA_Lang_menuP__msg = \1||scred_NLS_string('OSA_Lang_menuP__msg')
OSA_synt_chk_menuP__msg = \1||scred_NLS_string('OSA_synt_chk_menuP__msg')
OSA_Show_Results_menuP__msg = \1||scred_NLS_string('OSA_Show_Results_menuP__msg')
Scred_file_erase_warning = scred_NLS_string('Scred_file_erase_warning')
Scred_file_erase_warning2 = scred_NLS_string('Scred_file_erase_warning2')
Script_Editor_EPM_title = scred_NLS_string('Script_Editor_EPM_title')
Default_Script_Comp_name = scred_NLS_string('Default_Script_Comp_name')
Scred_Play_toolbar_title = scred_NLS_string('Scred_Play_toolbar_title')
Scred_Stop_toolbar_title = scred_NLS_string('Scred_Stop_toolbar_title')
Scred_Record_toolbar_title = scred_NLS_string('Scred_Record_toolbar_title')
Scred_synt_chk_toolbar_title = scred_NLS_string('Scred_synt_chk_toolbar_title')
Scred_Script_lang_toolbar_title_head = scred_NLS_string('Scred_Script_lang_toolbar_title_head')
Scred_Recording_statusline_title = scred_NLS_string('Scred_Recording_statusline_title')
Scred_Recording_suspended_statusline_title = scred_NLS_string('Scred_Recording_suspended_statusline_title')
OSA_language = Default_Script_Comp_name ---
;; now initialize the dll:
;;sayerror 'window = ' getpminfo(EPMINFO_EDITCLIENT) ' ...'
log_file_name0 = LOG_FILE_NAME||\0
initretc = dynalink32('scredrec','SCREDREC_EPM_Init',
gethwndc(EPMINFO_EDITCLIENT) ||
atol(DO_AE_INIT) ||
address(log_file_name0), 2)
if initretc <> 0 then
sayerror scred_NLS_string('Scred_EPM_Init_err_msg')|| initretc || '.'
endif
len = dynalink32('scredrec','get_comp_name_length', 0, 2)
if len = 0 then
sayerror scred_NLS_string('Scred_EPM_comp_name_missing_msg')
else
bufadr = dynalink32('scredrec','get_comp_name', 0, 2)
if bufadr = 0 then
sayerror scred_NLS_string('Scred_EPM_comp_name_inaccessible_msg')
else
OSA_language = oldpeek32(bufadr,len)
;; sayerror scred_NLS_string('Scred_EPM_comp_name_msg') || OSA_language || ' ...'
endif
endif
len = dynalink32('scredrec','get_temp_file_name_length', 0, 2)
if len = 0 then
sayerror scred_NLS_string('Scred_EPM_temp_file_name_missing_msg')
else
bufadr = dynalink32('scredrec','get_temp_file_name', 0, 2)
if bufadr = 0 then
sayerror scred_NLS_string('Scred_EPM_temp_file_name_inaccessible_msg')
else
tmp_fn = oldpeek32(bufadr,len)
;; sayerror scred_NLS_string('Scred_EPM_temp_file_name_msg') || tmp_fn || ' ...'
endif
endif
menuname = 'default'
;;; deletemenu menuname, 1, 0, 1 -- Delete the file menu
;;; buildsubmenu menuname, 1, FILE_BAR__MSG, FILE_BARP__MSG, 0 , mpfrom2short(HP_FILE, 0)
;;; buildmenuitem menuname, 1, 198, NEW_MENU__MSG, 'NEW'NEW_MENUP__MSG, 0, mpfrom2short(HP_FILE_NEW, 0)
;;; buildmenuitem menuname, 1, 199, OPEN_NEW_MENU__MSG, 'OPEN'OPEN_NEW_MENUP__MSG, 0, mpfrom2short(HP_FILE_OPEN_NEW, 0)
; buildmenuitem menuname, 1, 200, OPEN_MENU__MSG\9 || CTRL_KEY__MSG'+O', 'OPENDLG'OPEN_MENUP__MSG, 0, mpfrom2short(HP_FILE_OPEN, 0)
;;; buildmenuitem menuname, 1, 200, OPEN_MENU__MSG\9 || CTRL_KEY__MSG'+O', 'OSA_load_new'ADD_MENUP__MSG, 0, mpfrom2short(HP_FILE_OPEN, 0)
;;; buildmenuitem menuname, 1, 201, GET_MENU__MSG, 'OPENDLG GET'GET_MENUP__MSG, 0, mpfrom2short(HP_FILE_GET , 0)
; buildmenuitem menuname, 1, 202, ADD_MENU__MSG\9'Ctrl+O', 'OPENDLG EDIT'ADD_MENUP__MSG, 0, mpfrom2short(HP_FILE_EDIT, 0)
; buildmenuitem menuname, 1, 202, ADD_MENU__MSG\9'F8', 'osa_load_new'ADD_MENUP__MSG, 0, mpfrom2short(HP_FILE_EDIT, 0)
buildmenuitem menuname, 1, 102, SAMEWIN_MENU__MSG\9'F8', 'osa_load_new'ADD_MENUP__MSG, 0, mpfrom2short(HP_FILE_SAMEWIN, 0)
;;; buildmenuitem menuname, 1, 203, \0, '', 4, 0
;;; buildmenuitem menuname, 1, 204, RENAME_MENU__MSG\9'F7', 'rename'RENAME_MENUP__MSG,0, mpfrom2short(HP_FILE_NAME, 0)
;;; buildmenuitem menuname, 1, 205, \0, '', 4, 0
;;; buildmenuitem menuname, 1, 210, SAVE_MENU__MSG\9'F2', 'SAVE'SAVE_MENUP__MSG, 0, mpfrom2short(HP_FILE_SAVE, 0)
;;; compile if EVERSION >= '5.21'
;;; buildmenuitem menuname, 1, 211, SAVEAS_MENU__MSG, 'SAVEAS_DLG'SAVEAS_MENUP__MSG, 0, mpfrom2short(HP_FILE_SAVEAS, 0)
;;;compile endif
;;; buildmenuitem menuname, 1, 212, SAVECLOSE_MENU__MSG\9'F4', 'FILE'FILE_MENUP__MSG, 0, mpfrom2short(HP_FILE_FILE, 0)
;;; buildmenuitem menuname, 1, 213, QUIT_MENU__MSG\9'F3', 'QUIT'QUIT_MENUP__MSG, 0, mpfrom2short(HP_FILE_QUIT, 0)
;;; buildmenuitem menuname, 1, 214, \0, '', 4, 0
;;; compile if EVERSION < '5.51'
;;; buildmenuitem menuname, 1, 215, PRT_FILE_MENU__MSG, 'xcom save' default_printer()PRT_FILE_MENUP__MSG, 0, mpfrom2short(HP_FILE_PRINT, 0)
;;; compile else
;;; buildmenuitem menuname, 1, 215, PRT_FILE_MENU__MSG, 'xcom save /s /ne' default_printer()PRT_FILE_MENUP__MSG, 0, mpfrom2short(HP_FILE_PRINT, 0)
;;; compile endif
deletemenu menuname, HELP_MENU_ID, 0, 0 -- Delete the help menu
osa_menu_ID = HELP_MENU_ID + 4
buildsubmenu menuname, osa_menu_ID, OSA_bar__msg, OSA_barp__msg, 0 , mpfrom2short(HP_OSA,0)
buildmenuitem menuname, osa_menu_ID, 800, OSA_Compile_Menu__msg\9'F6', 'osa_compile'OSA_Compile_menuP__msg, 0, mpfrom2short(HP_OSA_Compile,0)
buildmenuitem menuname, osa_menu_ID, 805, \0, '', 4, 0
;;; buildmenuitem menuname, osa_menu_ID, 810, OSA_Install_Menu__msg, 'osa_install', 0, mpfrom2short(HP_OSA_Install,0)
;;; buildmenuitem menuname, osa_menu_ID, 815, \0, '', 4, 0
buildmenuitem menuname, osa_menu_ID, 820, OSA_Dictionary_Menu__msg\9'F12', 'osa_dictionary'OSA_Dictionary_menuP__msg, 0, mpfrom2short(HP_OSA_Dictionary,0)
buildmenuitem menuname, osa_menu_ID, 825, \0, '', 4, 0
buildmenuitem menuname, osa_menu_ID, 830, OSA_Lang_Menu__msg, OSA_Lang_menuP__msg, 0, mpfrom2short(HP_OSA_Language,0)
buildmenuitem menuname, osa_menu_ID, 835, \0, '', 4, 0
buildmenuitem menuname, osa_menu_ID, 840, OSA_synt_chk_Menu__msg, 'do_scred_synt_check'OSA_synt_chk_menuP__msg, 0, mpfrom2short(HP_OSA_SynCheck,0)
buildmenuitem menuname, osa_menu_ID, 845, \0, '', 4, 0
buildmenuitem menuname, osa_menu_ID, 850, OSA_Play_Menu__msg, 'do_push_play_button'OSA_Play_menuP__msg, 0, mpfrom2short(HP_OSA_Play,0)
buildmenuitem menuname, osa_menu_ID, 852, \0, '', 4, 0
buildmenuitem menuname, osa_menu_ID, 853, OSA_Show_Results_Menu__msg, 'do_show_results'OSA_Show_Results_menuP__msg, 0, mpfrom2short(HP_OSA_ShowResults,0)
buildmenuitem menuname, osa_menu_ID, 855, \0, '', 4, 0
buildmenuitem menuname, osa_menu_ID, 860, OSA_Stop_Menu__msg, 'do_push_stop_button'OSA_Stop_menuP__msg, 0, mpfrom2short(HP_OSA_StopRec,0)
buildmenuitem menuname, osa_menu_ID, 865, \0, '', 4, 0
buildmenuitem menuname, osa_menu_ID, 870, OSA_Record_Menu__msg, 'do_push_record_button'OSA_Record_menuP__msg, 0, mpfrom2short(HP_OSA_StartRec,0)
new_HELP_MENU_ID = HELP_MENU_ID + 10;
; stolen from stdmenu.e
buildsubmenu menuname, new_HELP_MENU_ID, HELP_BAR__MSG, 'help'HELP_BARP__MSG, /* 512 */ 0, mpfrom2short(HP_HELP, 0)
buildmenuitem menuname, new_HELP_MENU_ID, 600, HELP_INDEX_MENU__MSG, 'helpmenu 10'/*64044*/HELP_INDEX_MENUP__MSG, 0, mpfrom2short(HP_HELP_INDEX, 0)
buildmenuitem menuname, new_HELP_MENU_ID, 601, EXT_HELP_MENU__MSG, 'helpmenu 4000'EXT_HELP_MENUP__MSG, 0, mpfrom2short(HP_HELP_EXTENDED, 0)
buildmenuitem menuname, new_HELP_MENU_ID, 602, HELP_HELP_MENU__MSG, 'helpmenu 64027'HELP_HELP_MENUP__MSG, 0, mpfrom2short(HP_HELP_HELP, 0)
buildmenuitem menuname, new_HELP_MENU_ID, 603, KEYS_HELP_MENU__MSG, 'helpmenu 1000'KEYS_HELP_MENUP__MSG, 0, mpfrom2short(HP_HELP_KEYS, 0)
buildmenuitem menuname, new_HELP_MENU_ID, 604, COMMANDS_HELP_MENU__MSG,'helpmenu 2000'COMMANDS_HELP_MENUP__MSG, 0, mpfrom2short(HP_HELP_COMMANDS, 0)
buildmenuitem menuname, new_HELP_MENU_ID, 605, \0, '', 4, 0
buildmenuitem menuname, new_HELP_MENU_ID, 606, HELP_BROWSER_MENU__MSG, 'help'HELP_BROWSER_MENUP__MSG, 0, mpfrom2short(HP_HELP_BROWSE, 0)
buildmenuitem menuname, new_HELP_MENU_ID, 607, \0, '', 4, 0
compile if 0
buildmenuitem menuname, new_HELP_MENU_ID, 608, '#211'||(3-(screenxysize('X')>1000)), 'IBMmsg'HELP_PROD_MENUP__MSG, 2, mpfrom2short(HP_HELP_IBM, 0)
-- Resource # 2112 or 2113 in ERES.DLL
compile else
buildmenuitem menuname, new_HELP_MENU_ID, 608, HELP_PROD_MENU__MSG, 'IBMmsg'HELP_PROD_MENUP__MSG, 0, mpfrom2short(HP_HELP_PROD, 0)
compile endif
compile if SUPPORT_USERS_GUIDE | SUPPORT_TECHREF
buildmenuitem menuname, new_HELP_MENU_ID, 610, \0, '', 4, 0
compile if SUPPORT_USERS_GUIDE
buildmenuitem menuname, new_HELP_MENU_ID, 620, USERS_GUIDE_MENU__MSG, USERS_GUIDE_MENUP__MSG, 17+64, mpfrom2short(HP_HELP_USERS_GUIDE, 0)
buildmenuitem menuname, new_HELP_MENU_ID, 621, VIEW_USERS_MENU__MSG, 'view epmusers'VIEW_USERS_MENUP__MSG, 0, mpfrom2short(HP_HELP_USERS_GUIDE, 0)
buildmenuitem menuname, new_HELP_MENU_ID, 622, VIEW_IN_USERS_MENU__MSG, 'viewword epmusers'VIEW_IN_USERS_MENUP__MSG, 0, mpfrom2short(HP_HELP_USERS_GUIDE, 0)
buildmenuitem menuname, new_HELP_MENU_ID, 623, VIEW_USERS_SUMMARY_MENU__MSG, 'view epmusers Summary'VIEW_USERS_SUMMARY_MENUP__MSG, 32768+1, mpfrom2short(HP_HELP_USERS_GUIDE, 0)
compile endif
compile if SUPPORT_TECHREF
buildmenuitem menuname, new_HELP_MENU_ID, 630, TECHREF_MENU__MSG, TECHREF_MENUP__MSG, 17+64, mpfrom2short(HP_HELP_TECHREF, 0)
buildmenuitem menuname, new_HELP_MENU_ID, 631, VIEW_TECHREF_MENU__MSG, 'view epmtech'VIEW_TECHREF_MENUP__MSG, 0, mpfrom2short(HP_HELP_TECHREF, 0)
buildmenuitem menuname, new_HELP_MENU_ID, 632, VIEW_IN_TECHREF_MENU__MSG, 'viewword epmtech'VIEW_IN_TECHREF_MENUP__MSG, 32768+1, mpfrom2short(HP_HELP_TECHREF, 0)
compile endif
compile endif
showmenu menuname
'toggleframe 4 0' -- remove the rings from the upper right corner ...
menu = 'Toolbar'
deletemenu menu
call set_OSA_status()
.titletext = Script_Editor_EPM_title .filename
; fn = .filename
; if fn <> UNNAMED_FILE_NAME then
; 'xcom e /n'
; 'postme edit' fn
; endif
return
defc do_show_results =
;; sayerror scred_NLS_string('Scred_EPM_trying_async_action_msg') || SCREDREC_show_results || ' ...'
title = scred_NLS_string('Scred_EPM_Results_title')||\0
retc = dynalink32('scredrec','Try_async_action',
atol(SCREDREC_show_results) || address(title), 2)
return
defc push_play_button =
universal OSA_Play_menuP__msg
parse arg action_letter parms
if action_letter = 'S' then -- button selected
'do_push_play_button' parms
elseif action_letter = 'H' then -- help asked
'helpmenu' HP_OSA_Play
elseif action_letter = 'I' then -- button initialized
sayerror substr(OSA_Play_menuP__msg,2)
endif
defc do_push_play_button =
universal activeucmenu, toolbar_loaded
universal OSA_play, OSA_record
universal OSA_language
universal stable_bar
universal source_version, compiled_source_version, temp_source_version
universal tmp_fn, source_only
universal scredrec_modified
universal scredrec_last_modified
if OSA_play = OSA_on then
return
endif
;; update the source if the file is changed ...
if scredrec_last_modified <> .modify or source_version < compiled_source_version then
--- save source into a temp file ...
temp_source_version = source_version + 2
tmp = .modify
fn = .filename
'xcom save ' tmp_fn
tmp_fn0 = tmp_fn||\0
.filename = fn
.modify = tmp
retc = dynalink32('scredrec','Update_Source',
address(tmp_fn0) || atol(0), 2) -- don't remove the file
if retc <> 0 then
sayerror scred_NLS_string('Scred_EPM_Update_source_msg') || retc || ' ...'
temp_source_version = 0
else
source_version = temp_source_version - 1
scredrec_last_modified = .modify
source_only = OSA_on
scredrec_modified = 1
endif
endif
;; sayerror scred_NLS_string('Scred_EPM_trying_async_action_msg') || SCREDREC_play || ' ...'
retc = dynalink32('scredrec','Try_async_action',
atol(SCREDREC_play) || NULL, 2)
OSA_play = OSA_on
call set_OSA_status()
return
defproc finish_push_play_button(msg_value)
universal activeucmenu, toolbar_loaded
universal OSA_play, OSA_record
universal OSA_language
universal stable_bar
if msg_value = SCREDREC_failure then
sayerror scred_NLS_string('Scred_EPM_Play_err_msg')
endif
OSA_play = OSA_off
call set_OSA_status()
return
defc push_record_button =
universal OSA_Record_menuP__msg
parse arg action_letter parms
if action_letter = 'S' then -- button selected
'do_push_record_button' parms
elseif action_letter = 'H' then -- help asked
'helpmenu' HP_OSA_StartRec
elseif action_letter = 'I' then -- button initialized
sayerror substr(OSA_Record_menuP__msg,2)
endif
defc do_push_record_button =
universal activeucmenu, toolbar_loaded
universal OSA_play, OSA_record
universal OSA_language
universal stable_bar
;; Recording disabled ...
sayerror scred_NLS_string('Scred_EPM_Recording_disabled_msg')
return
if OSA_record <> OSA_suspended and OSA_record <> OSA_off then
return
endif
OSA_record = OSA_started
;; sayerror scred_NLS_string('Scred_EPM_trying_async_action_msg') || SCREDREC_record || ' ...'
retc = dynalink32('scredrec','Try_async_action',
atol(SCREDREC_record) || NULL, 2)
;; if retc <> 0 then
;; sayerror 'error initializing Recording ... retc = ' retc '.'
;; OSA_record = OSA_off
;; endif
return
defproc finish_push_record_button(msg_value)
universal activeucmenu, toolbar_loaded
universal OSA_play, OSA_record
universal OSA_language
universal stable_bar
if msg_value = SCREDREC_failure then
sayerror scred_NLS_string('Scred_EPM_StartRec_err_msg')
OSA_record = OSA_off
else
OSA_record = OSA_on
endif
call set_OSA_status()
return
defc push_stop_button =
universal OSA_Stop_menuP__msg
parse arg action_letter parms
if action_letter = 'S' then -- button selected
'do_push_stop_button' parms
elseif action_letter = 'H' then -- help asked
'helpmenu' HP_OSA_StopRec
elseif action_letter = 'I' then -- button initialized
sayerror substr(OSA_Stop_menuP__msg,2)
endif
defc do_push_stop_button =
universal activeucmenu, toolbar_loaded
universal OSA_play, OSA_record
universal OSA_language
universal stable_bar
if OSA_play <> OSA_on and OSA_record <> OSA_on then
return
endif
; sayerror 'OSA language = '||OSA_language || ' ...'
; this doesn't work yet - we cannot stop OSAExecute ...
; if OSA_play = OSA_on then
; OSA_play = OSA_off
; endif
if OSA_record = OSA_on then
OSA_record = OSA_dying
endif
;; sayerror scred_NLS_string('Scred_EPM_trying_async_action_msg') || SCREDREC_stop || ' ...'
retc = dynalink32('scredrec','Try_async_action',
atol(SCREDREC_stop) || NULL, 2)
;; if retc <> 0 then
;; sayerror 'error stopping Recording ... retc = ' retc '.'
;; OSA_record = OSA_on
;; endif
;; endif
call set_OSA_status()
defproc finish_stop_recording(msg_value)
universal activeucmenu, toolbar_loaded
universal OSA_play, OSA_record
universal OSA_language
universal stable_bar
if OSA_record <> OSA_dying then
return
endif
if msg_value = SCREDREC_failure then
sayerror scred_NLS_string('Scred_EPM_StopRec_err_msg')
OSA_record = OSA_on
else
OSA_record = OSA_suspended
endif
call set_OSA_status()
return
defc scred_synt_check =
universal OSA_synt_chk_menuP__msg
parse arg action_letter parms
if action_letter = 'S' then -- button selected
'do_scred_synt_check' parms
elseif action_letter = 'H' then -- help asked
'helpmenu' HP_OSA_SynCheck
elseif action_letter = 'I' then -- button initialized
sayerror substr(OSA_synt_chk_menuP__msg,2)
endif
defc do_scred_synt_check =
universal activeucmenu, toolbar_loaded
universal OSA_synt_check
universal stable_bar
if OSA_synt_check = OSA_off then
--- set syntax check on ...
sayerror scred_NLS_string('Scred_EPM_syn_chk_enabled_msg')
'toggle_parse 1 epmkwds.orx'
OSA_synt_check = OSA_on
else
sayerror scred_NLS_string('Scred_EPM_syn_chk_disabled_msg')
'toggle_parse 0'
OSA_synt_check = OSA_off
endif
if stable_bar = OSA_off then
call set_OSA_status()
endif
defc osa_compile=
universal source_version, compiled_source_version, temp_source_version
universal tmp_fn, source_only
universal scredrec_modified
universal scredrec_last_modified
;; scredrec_modified = 0
if temp_source_version <> 0 then
sayerror scred_NLS_string('Scred_EPM_Already_compiling_err_msg')
return 0
endif
-- temp source version is one more than the target compiled source version ...
temp_source_version = source_version +1
if scredrec_last_modified <> .modify or source_version < compiled_source_version then
--- save source into a temp file ...
temp_source_version = source_version + 2
tmp = .modify
fn = .filename
'xcom save ' tmp_fn
tmp_fn0 = tmp_fn||\0
.filename = fn
.modify = tmp
retc = dynalink32('scredrec','Update_Source',
address(tmp_fn0) || atol(0), 2) -- don't remove the file
if retc <> 0 then
sayerror scred_NLS_string('Scred_EPM_Update_source_msg') || retc || ' ...'
temp_source_version = 0
else
source_version = temp_source_version - 1
scredrec_last_modified = .modify
source_only = OSA_on
scredrec_modified = 1
endif
endif
if temp_source_version > 0 then
;; sayerror scred_NLS_string('Scred_EPM_trying_async_action_msg') || SCREDREC_compile || ' ...'
retc = dynalink32('scredrec','Try_async_action',
atol(SCREDREC_compile) || NULL, 2)
endif
defproc finish_compile(msg_value)
universal source_version, compiled_source_version, temp_source_version
universal tmp_fn
universal scredrec_modified
universal scredrec_last_modified
if msg_value = SCREDREC_failure then
sayerror scred_NLS_string('Scred_EPM_Compile_err_msg')
else
sayerror scred_NLS_string('Scred_EPM_Compile_success_msg')
scredrec_modified = 1
source_only = OSA_off
if temp_source_version <> 0 then
compiled_source_version = temp_source_version - 1
endif
endif
temp_source_version = 0
defc osa_install=
sayerror scred_NLS_string('Scred_EPM_install_not_implemented_msg')
defc osa_dictionary=
;; sayerror 'OSA dictionary opened ...'
-- first, find the list of AETEs ...
aete_list_len = dynalink32('scredrec','get_aete_list_length', , 2)
;; sayerror 'len = ' aete_list_len
if aete_list_len = 0 then -- no applications???
;; sayerror 'on the 1st call to OSAListApplications, list length = 0 ...'
return 0
endif
aete_list = copies(\0,aete_list_len)
len = atol(aete_list_len)
retc = dynalink32('scredrec','get_aete_list',
address(aete_list) || address(len) , 2)
if retc<>0 then -- no applications, or buffer too small???
;; sayerror 'on the 2nd call to OSAListApplications, retc =' retc ' ...'
return 0
endif
new_aete_list_len = ltoa(len,10)
;; sayerror 'new length is ' new_aete_list_len
if new_aete_list_len<2 then -- no applications??
return 0
endif
if new_aete_list_len < aete_list_len then
aete_list = leftstr(aete_list,new_aete_list_len)
endif
if rightstr(aete_list,1) <> \1 then
aete_list = aete_list || \1
endif
aete_list = \1 || aete_list
;; sayerror 'calling listbox ...'
aete = listbox(scred_NLS_string('Scred_EPM_Select_app_msg'), aete_list)
if aete=='' then -- didn't select any app
return 0
endif
;; sayerror 'aete' aete 'selected ...'
aete0 = aete||\0
retc = dynalink32('scredrec','show_aete',
address(aete0) , 2)
if retc<>0 then -- problems with Print ???
;; sayerror 'on the call to show_aete, retc =' retc '...'
return 0
endif
return
defc osa_load_new=
universal scredrec_modified
universal Scred_file_erase_warning, Scred_file_erase_warning2
if .modify>0 or scredrec_modified<>0 then
res = winmessagebox(Scred_file_erase_warning, Scred_file_erase_warning2,
MB_OKCANCEL + MB_DEFBUTTON2)
if res <> MBID_OK then
return
endif
endif
'opendlg edit'
def f12='osa_dictionary'
def f6='osa_compile'
def f4=
universal scredrec_modified
if .modify > 0 or scredrec_modified <> 0 then
'File'
else
'Quit'
endif
;def f5,c_O=
; 'opendlg'
def f8=
'osa_load_new'
; sayerror NO_RING__MSG
; return
;; old peek32 function, without the offset field; the interface was changed in EPM 6.03 ...
defproc oldpeek32(bufaddr,len)
compile if EVERSION > 6.025
return peek32(bufaddr,0,len)
compile else
return peek32(bufaddr,len)
compile endif
;; for debug only: sometimes EPM loses its file id ...
defc sayfileid
getfileid id
sayerror 'file id is '|| id ||' ('||length(id)||' chars) now ...'
;; keep only one file in the ring
;;defload
defselect
'postme keep_one_file_in_the_ring'
defc keep_one_file_in_the_ring
universal Script_Editor_EPM_title
;; sayerror "keeping one file in the ring ..."
getfileid startid
;; sayerror 'startid = ' startid
;; sometimes EPM forgets its fileid; the following lines try to recover it ...
if startid = '' then
do i=1 to 5
nextfile
getfileid nextid
if nextid <> '' then
;; sayerror "recovering id =" nextid||", i="||i"."
refresh
return
endif
end
nextfile
refresh
return
endif
; return
;; sayerror filesinring() 'files in ring ...'
if filesinring() < 2 then
return
endif
-- temp fix for the toolbar commands ...
;; if rightstr(.filename,11) == 'actions.lst' then
;; return
;; endif
n = filesinring()-1
do i=1 to n
nextfile
getfileid nextid
if startid <> nextid then
.modify = 0
'xcom quit'
endif
enddo
activatefile startid
.titletext = Script_Editor_EPM_title .filename
refresh
return
; the save command is rewritten in order to read the right source from the script file ...
defc s,save=
universal default_save_options
universal source_version, compiled_source_version, temp_source_version
universal tmp_fn, source_only
universal scredrec_modified
universal scredrec_last_modified
universal Script_Editor_EPM_title
name=arg(1)
call parse_leading_options(name,options)
;; sayerror 'saving a file, name = ' name ', options = ' options '.'
options = default_save_options options
save_as = 0
name=.filename
if name='' | name=UNNAMED_FILE_NAME then
result = saveas_dlg(name, type)
if result then return result; endif -- cancel
if name<>.filename then
;; sayerror 'new name = ' name ' ...'
.filename = name
endif
;; 'name' name
;; if not rc then
;; name=.filename
;; save_as = 1
;; endif
else
call parse_filename(name,.filename)
endif
if leftstr(name,1) = '"' then --- quoted string ...
name = rightstr(name, length(name) -1)
if rightstr(name,1) = '"' then --- quoted string ...
name = leftstr(name, length(name) -1)
endif
endif
;; sayerror 'last name = ' name ' ...'
;; if .modify > 0 then
if scredrec_last_modified <> .modify then
--- save source into a temp file ...
;; sayerror 'save source into a temp file ' tmp_fn ' ...'
tmp = .modify
fn = .filename
'xcom save ' tmp_fn
tmp_fn0 = tmp_fn||\0
.filename = fn
.modify = tmp
retc = dynalink32('scredrec','Update_Source',
address(tmp_fn0) || atol(0), 2) -- don't remove the file
if retc <> 0 then
sayerror scred_NLS_string('Scred_EPM_Update_source_msg') || retc || ' ...'
else
source_version = tmp
source_only = OSA_on
source_version = source_version + 1
scredrec_last_modified = .modify
scredrec_modified = 1
endif
endif
;;; should it be compiled now??
name0 = name || \0
retc = dynalink32('scredrec','Save_the_file', address(name0), 2)
if retc <> 0 then
sayerror scred_NLS_string('Scred_EPM_Save_the_file_msg') || retc || ' ...'
else
.modify = 0
scredrec_last_modified = 0
scredrec_modified = 0
endif
.titletext = Script_Editor_EPM_title .filename
defc File=
'save' arg(1)
'Quit'
; the edit command is rewritten in order to read the right source from the script file ...
defc e,ed,edit,epm=
universal default_edit_options
universal source_version, compiled_source_version, temp_source_version
universal tmp_fn, source_only
universal scredrec_modified
universal scredrec_last_modified
universal OSA_synt_check
universal Script_Editor_EPM_title
args=strip(arg(1))
source_update = 1 --- default
options=default_edit_options
do while leftstr(args,1) = "/"
parse value args with opt args
opt = upcase(opt)
if opt = "/SCRED_GET" then
source_update = 0
else
options = options opt
endif
enddo
if args = '=' then
args = .filename
endif
if leftstr(args,1) = '"' then --- quoted string ...
firstfile = rightstr(args, length(args) -1) /* left quote removed ... */
p = pos('"',firstfile)
if p > 0 then
firstfile = leftstr(firstfile, p-1) /* right quote and the tail removed ... */
endif
else
parse value args with firstfile .
endif
;; sayerror 'files loaded: 1st file is 'firstfile' ...'
-- temp fix for the toolbar commands ...
if rightstr(firstfile,11) == 'actions.lst' then
'xcom e' arg(1)
return 0
endif
if firstfile='' or firstfile = '=' then /* 'edit' by itself goes to the next file */
return 0
else
secondfile = copies(\0,257)
firstfile0 = firstfile||\0
retc = dynalink32('scredrec','Read_the_file', address(firstfile0) ||
address(secondfile) ||
atol(source_update) , 2)
if retc = SCREDREC_file_not_found and
qfilemode(fistfile,junkattr) = 2 then -- file name is OK, but the file doesn't exist
retc2 = dynalink32('scredrec','make_empty_file',0,2)
if retc2 = 0 then
;; sayerror 'loading empty file' firstfile
'xcom e /n' options
source_only = OSA_on
source_version = 1
.filename = firstfile
compiled_source_version = 0
temp_source_version = 0
scredrec_modified = 0
scredrec_last_modified = 0
if OSA_synt_check = OSA_off then
'toggle_parse 0'
else
'toggle_parse 1 epmkwds.orx'
endif
if source_update > 0 then
'postme keep_one_file_in_the_ring'
endif
return 0
endif
endif
if retc <> 0 then
sayerror scred_NLS_string('Scred_EPM_Load_file_err_msg') || firstfile || ', ... retc = ' || retc || '.'
return 0
endif
len = pos(\0,secondfile) -1
if len > 0 then
fn = leftstr(secondfile,len)
if fn = firstfile then
;; sayerror 'loading source file ...'
source_only = OSA_on
source_version = 1
else
;; sayerror 'loading compiled script file, temp file is ' fn ' ...'
source_only = OSA_off
source_version = 0
endif
;; 'xcom e /d' options fn -- reload if needed ...
loadfile(fn,"/D "options)
.filename = firstfile
compiled_source_version = 0
temp_source_version = 0
scredrec_modified = 0
scredrec_last_modified = 0
if OSA_synt_check = OSA_off then
'toggle_parse 0'
else
'toggle_parse 1 epmkwds.orx'
endif
if source_update > 0 then
'postme keep_one_file_in_the_ring'
endif
else
sayerror scred_NLS_string('Scred_EPM_Load_file_err_msg') || firstfile || ' ...'
endif
endif
.titletext = Script_Editor_EPM_title .filename
; use the status line instead of toolbar to show the state of SCREDREC ...
defproc make_stable_bar()
universal stable_bar
universal Scred_Stop_toolbar_title
stable_bar = OSA_on
; sayerror 'stable_bar set ...'
--- set the toolbar ...
menu = 'Toolbar'
buildsubmenu menu , 2, "#"||Scred_Stop_toolbar_title||"#scrstop.bmp#push_stop_button", '', 0, 0
buildsubmenu menu , 4, "##scrempty.bmp#",'', 0, 0
showmenu menu, 3
toolbar_loaded = 'scredrec'
refresh
call set_OSA_status()
defproc set_OSA_status()
universal activeucmenu, toolbar_loaded
universal OSA_play, OSA_record, OSA_synt_check
universal OSA_language
universal stable_bar
universal Scred_Play_toolbar_title
universal Scred_Stop_toolbar_title
universal Scred_Record_toolbar_title
universal Scred_synt_chk_toolbar_title
universal Scred_Script_lang_toolbar_title_head
universal Scred_Recording_statusline_title
universal Scred_Recording_suspended_statusline_title
;; sayerror 'OSA_play = ' OSA_play ', OSA_record = ' OSA_record ', OSA_synt_check = ' OSA_synt_check ' ...'
if stable_bar = OSA_off then
-- change the toolbar ...
menu = 'Toolbar'
activeucmenu = menu
stop_enabled = OSA_off
if OSA_play = OSA_off then
buildsubmenu menu , 1, "#"||Scred_Play_toolbar_title||"#scrplay.bmp#push_play_button", '', 0, mpfrom2short(HP_OSA_Play,0)
else
buildsubmenu menu , 1, "#"||Scred_Play_toolbar_title||"#scrplayp.bmp#push_play_button", '', 0, mpfrom2short(HP_OSA_Play,0)
stop_enabled = OSA_on
endif
if OSA_record = OSA_on then
stop_enabled = OSA_on
endif
if stop_enabled = OSA_on then
buildsubmenu menu , 2, "#"||Scred_Stop_toolbar_title||"#scrstop.bmp#push_stop_button", '', 0, mpfrom2short(HP_OSA_StopRec,0)
else
buildsubmenu menu , 2, "#"||Scred_Stop_toolbar_title||"#scrstopp.bmp#push_stop_button", '', 0, mpfrom2short(HP_OSA_StopRec,0)
endif
if OSA_record = OSA_on or OSA_record = OSA_dying then
buildsubmenu menu , 3, "#"||Scred_Record_toolbar_title||"#scr_recp.bmp#push_record_button", '', 0, mpfrom2short(HP_OSA_StartRec,0)
buildsubmenu menu , 4, "#"||Scred_Script_lang_toolbar_title_head||OSA_language||"#scremptr.bmp#",'', 0, 0
else -- off, suspended, or started
buildsubmenu menu , 3, "#"||Scred_Record_toolbar_title||"#scr_rec.bmp#push_record_button", '', 0, mpfrom2short(HP_OSA_StartRec,0)
buildsubmenu menu , 4, "#"||Scred_Script_lang_toolbar_title_head||OSA_language||"#scrempty.bmp#",'', 0, 0
endif
if OSA_synt_check = OSA_on then
buildsubmenu menu , 28, "#"||Scred_synt_chk_toolbar_title||"#scrschkp.bmp#scred_synt_check", '',0, mpfrom2short(HP_OSA_SynCheck,0)
else
buildsubmenu menu , 28, "#"||Scred_synt_chk_toolbar_title||"#scrschk.bmp#scred_synt_check", '',0, mpfrom2short(HP_OSA_SynCheck,0)
endif
refresh
showmenu menu, 3
toolbar_loaded = 'scredrec'
else
-- change the status line ...
statl = STATUS_TEMPLATE__MSG||OSA_language
rec=""
if OSA_record = OSA_on then
rec=Scred_Recording_statusline_title
endif
if OSA_record = OSA_suspended then
rec=Scred_Recording_suspended_statusline_title
endif
statl = statl||rec
'setstatusline' statl
endif
return
;; get an info msg and issue the corresponding command if needed ...
defc scredrec_inf
parse arg sender msg_type msg_value
;; sayerror 'sender is' sender ', msg_type is ' msg_type ', and msg_value is ' msg_value ' ...'
--- temporary fix
msg_value = leftstr(msg_value, 1)
if msg_type = SCREDREC_StartRecording_msg then
;; sayerror 'SCREDREC_StartRecording_msg ...'
call finish_push_record_button(msg_value)
return
endif
if msg_type = SCREDREC_StopRecording_msg then
;; sayerror 'SCREDREC_StopRecording_msg ...'
call finish_stop_recording(msg_value)
return
endif
if msg_type = SCREDREC_Play_msg then
;; sayerror 'SCREDREC_Play_msg ...'
call finish_push_play_button(msg_value)
return
endif
if msg_type = SCREDREC_Compile_msg then
;; sayerror 'SCREDREC_Compile_msg ...'
call finish_compile(msg_value)
return
endif
return
;; a command to add source lines, meanwhile without style info ...
defc scredrec_add
parse arg text_addr len .
if text_addr = 0 or text_addr = '' then
return
endif
if len <= 0 or len = '' then
return
endif
bufaddr = atol(text_addr)
text = oldpeek32(bufaddr,len)
first = 1
LF = substr(atoi(10),1,1) -- \n ...
CR = substr(atoi(13),1,1) -- \r ...
eol = CR||LF
while len > 0 do
linend = verify(text, eol, 'match', first)
if linend = 0 then -- end of line not found ...
line = substr(text,first,len)
len = 0
else
line = substr(text,first,linend-first)
len = len - (linend-first) -1 -- counting eol
next = linend + 1
lastchar = substr(text,linend,1)
nextchar = substr(text,next,1)
if lastchar <> nextchar and pos(nextchar,eol) > 0 then -- catching CR||LF or LF||CR
next = next +1
len = len -1
endif
endif
insertline line, .last + 1
first = next
endwhile
--- now, free the text buffer and return ...
retc = dynalink32('scredrec','free_buf', bufaddr, 2)
return
;;; the following is only for debugging ...
defc set_recording
universal OSA_play, OSA_record, OSA_synt_check
parse arg s
if s = '' then -- unset
OSA_record = OSA_off
else
OSA_record = OSA_on
endif
call set_OSA_status()
return
defc set_play
universal OSA_play, OSA_record, OSA_synt_check
parse arg s
if s = '' then -- unset
OSA_play = OSA_off
else
OSA_play = OSA_on
endif
call set_OSA_status()
return
defc print_scredrec_global_vars
universal source_version, compiled_source_version, temp_source_version
universal tmp_fn, source_only
universal scredrec_modified
universal scredrec_last_modified
sayerror 'source_version =' source_version
sayerror 'compiled_source_version =' compiled_source_version
sayerror 'temp_source_version =' temp_source_version
sayerror 'tmp_fn =' tmp_fn
sayerror 'source_only =' source_only
sayerror 'scredrec_modified =' scredrec_modified
sayerror 'scredrec_last_modified =' scredrec_last_modified
;; get command should add EDIT option 'scred_get' to avoid updating source&compiled IDs ...
defc get=
universal default_edit_options
;;'echo on'
get_file = strip(arg(1))
if get_file='' then sayerror NO_FILENAME__MSG 'GET'; stop endif
if pos(argsep,get_file) then
sayerror INVALID_OPTION__MSG
stop
endif
call parse_filename(get_file,.filename)
getfileid fileid
s_last=.last
display -1
'e /scred_get /q /d' get_file
editrc=rc
.visible = 0
getfileid gfileid
refresh
if editrc = -282 | not .last | gfileid = fileid then -- -282 = sayerror('New file')
display 1
if editrc = -282 | gfileid = fileid then
sayerror FILE_NOT_FOUND__MSG': 'get_file
else
sayerror FILE_IS_EMPTY__MSG': 'get_file
endif
activatefile fileid
refresh
;; 'postme keep_one_file_in_the_ring'
stop
endif
if editrc & editrc<>-278 then -- -278 sayerror('Lines truncated') then
display 1
sayerror editrc
activatefile fileid
refresh
;; 'postme keep_one_file_in_the_ring'
stop
endif
call psave_mark(save_mark)
compile if WANT_BOOKMARKS
if not .levelofattributesupport then
'loadattributes'
endif
compile endif
get_file_attrib = .levelofattributesupport
top
mark_line
bottom
mark_line
activatefile fileid
rc=0
copy_mark
copy_rc=rc -- Test for memory too full for copy_mark.
activatefile gfileid
'xcom q'
parse value save_mark with s_firstline s_lastline s_firstcol s_lastcol s_mkfileid s_mt
if fileid=s_mkfileid then -- May have to move the mark.
diff=fileid.last-s_last -- (Adjustment for difference in size)
if fileid.line<s_firstline then s_firstline=s_firstline+diff; endif
if fileid.line<s_lastline then s_lastline=s_lastline+diff; endif
endif
call prestore_mark(s_firstline s_lastline s_firstcol s_lastcol s_mkfileid s_mt)
activatefile fileid
if get_file_attrib // 2 then
call attribute_on(1) -- Colors flag
endif
if get_file_attrib bitand 4 then
call attribute_on(4) -- Mixed fonts flag
endif
if get_file_attrib bitand 8 then
call attribute_on(8) -- "Save attributes" flag
endif
display 1
if copy_rc then
sayerror NOT_2_COPIES__MSG get_file
endif
;;sayerror "get almost finished ..."
'postme keep_one_file_in_the_ring'
;; 'sayfileid'
stop
;; defc test_NLS_str
;; name = scred_NLS_string('OSA_bar__msg')
;; sayerror 'the OSA bar msg is ' name ' ...'
;; name = scred_NLS_string('Unknown_msg')
;; sayerror 'the Unknown msg is ' name ' ...'
;; get a string from a DLL; uses the function 'get_NLS_string_len' defined in SCREDREC.DLL
defproc scred_NLS_string(strname)
s = NULL
lib='scrednls'||\0
;; sayerror 'strname = ' strname ' ...'
strname=strname||\0
strlen = dynalink32('scredrec','get_NLS_string_len', address(lib)||
address(strname)||
address(s), 2)
if s == NULL then
strvalue = ' ... ' -- undefined ...
;; sayerror 'scred_NLS_string: strvalue undefined ...'
elseif strlen = 0 then
strvalue = ''
;; sayerror 'scred_NLS_string: strvalue empty str ...'
else
strvalue = oldpeek32(ltoa(s,10),strlen)
;; sayerror 'scred_NLS_string: strvalue' strvalue '...'
endif
return strvalue