home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / odrtime.zip / OPENPACK / EPM / SCREDREC.E < prev    next >
Text File  |  1995-11-22  |  46KB  |  1,264 lines

  1. ---- commands used by Script Editor and Recorder (SCREDREC)
  2.  
  3. #define  SUPPORT_USERS_GUIDE    1
  4. #define  SUPPORT_TECHREF        1
  5.  
  6.   compile if not defined(NLS_LANGUAGE)
  7.     const NLS_LANGUAGE = 'English'
  8.   compile endif
  9.  
  10.  compile if not defined(WANT_DYNAMIC_PROMPTS)
  11.    WANT_DYNAMIC_PROMPTS = 1
  12.  compile endif
  13.  
  14. include NLS_LANGUAGE'.e' 
  15. include 'stdconst.e' 
  16.  
  17. ; HP_* etc ....
  18. include 'menuhelp.h' 
  19. include 'scredhlp.h' 
  20.  
  21.     const
  22.       NULL = \0 || \0 || \0 || \0
  23.       DO_AE_INIT = 1
  24. ;; log file disabled ...
  25.       LOG_FILE_NAME = ''
  26. ;;      LOG_FILE_NAME = 'scredrec.log'
  27. ;;      OSA_DEFAULT_LANGUAGE = 'OREXX'
  28.  
  29. const
  30.    OSA_off = 0
  31.    OSA_on = 1
  32.    OSA_started = -1
  33.    OSA_dying = -2
  34.    OSA_suspended = -6
  35.  
  36. ;; constants, msg #s etc...
  37. include 'scredmsg.h' 
  38.  
  39. defc scredrec_start =
  40.  
  41.    arg_str = arg(1)
  42.    fn = ''
  43.    options = ''
  44.    while arg_str<>'' do
  45.       parse value arg_str with param arg_str
  46.       if pos(leftstr(param,1),"/-")>0 then         -- option
  47.          opt=substr(param,2)
  48.          if opt=='s' or opt=="S" then           -- stable bar
  49.             call make_stable_bar()
  50.          else
  51.             options = options param
  52.          endif
  53.       elseif fn == '' then
  54.          fn = param
  55.       endif
  56.    endwhile
  57.  
  58.    if fn <>'' then
  59.      .filename=fn' ...'
  60. ;;     sayerror 'wait for loading the file ...'
  61.      'postme edit' fn
  62.    endif
  63.  
  64. ;;   call set_OSA_status()
  65.  
  66.    return
  67.  
  68. definit
  69.  universal OSA_bar__msg 
  70.  universal OSA_Compile_Menu__msg 
  71.  universal OSA_Install_Menu__msg 
  72.  universal OSA_Dictionary_Menu__msg 
  73.  universal OSA_Play_Menu__msg 
  74.  universal OSA_Stop_Menu__msg 
  75.  universal OSA_Record_Menu__msg 
  76.  universal OSA_Lang_Menu__msg 
  77.  universal OSA_synt_chk_Menu__msg 
  78.  universal OSA_Show_Results_Menu__msg 
  79.  
  80.  universal OSA_barp__msg 
  81.  universal OSA_Compile_menuP__msg 
  82.  universal OSA_Dictionary_menuP__msg 
  83.  universal OSA_Play_menuP__msg 
  84.  universal OSA_Stop_menuP__msg 
  85.  universal OSA_Record_menuP__msg 
  86.  universal OSA_Lang_menuP__msg 
  87.  universal OSA_synt_chk_menuP__msg 
  88.  universal OSA_Show_Results_menuP__msg 
  89.  
  90.  universal Scred_file_erase_warning 
  91.  universal Scred_file_erase_warning2 
  92.  
  93.  universal Script_Editor_EPM_title
  94.  universal Default_Script_Comp_name
  95.  
  96.  universal Scred_Play_toolbar_title
  97.  universal Scred_Stop_toolbar_title
  98.  universal Scred_Record_toolbar_title
  99.  universal Scred_synt_chk_toolbar_title
  100.  universal Scred_Script_lang_toolbar_title_head
  101.  universal Scred_Recording_statusline_title
  102.  universal Scred_Recording_suspended_statusline_title
  103.  
  104.    universal activeucmenu, toolbar_loaded
  105.    universal OSA_language
  106.   
  107.    --- global vars to control playing/recording;
  108.    --- in the future, OSA_record will have 4 possible values,
  109.    ---  off, on, started, and dying;
  110.    --- meanwhile, both are boolean
  111.    universal OSA_play, OSA_record, OSA_synt_check
  112.    -- this says that the toolbar stays stable, and the Recording/playing info
  113.    -- is shown in the status line ...
  114.    universal stable_bar
  115.    universal source_version, compiled_source_version, temp_source_version
  116.    universal tmp_fn, source_only
  117.    universal scredrec_modified
  118.    universal scredrec_last_modified
  119.  
  120.    scredrec_modified = 0
  121.    scredrec_last_modified = 0
  122.    source_only = OSA_on
  123.    tmp_fn = ''
  124.    source_version = 0
  125.    compiled_source_version = 0
  126.    temp_source_version = 0
  127.    stable_bar = OSA_off
  128.    OSA_play = OSA_off
  129.    OSA_record = OSA_off
  130.    OSA_synt_check = OSA_off
  131.  
  132. ;;
  133.  
  134. ;; add SCREDREC help file ...
  135.   findfile scredrec_help, 'scredrec.hlp', 'EPMPATH'
  136.   if rc then
  137.     sayerror scred_NLS_string('Scred_EPM_file_not_found_msg')
  138.   endif
  139.   'compiler_help_add' scredrec_help
  140.  
  141. ;; get the NLS strings ...
  142.     OSA_bar__msg = TILDE_CHAR||scred_NLS_string('OSA_bar__msg') 
  143.     OSA_Compile_Menu__msg = scred_NLS_string('OSA_Compile_Menu__msg') 
  144.     OSA_Install_Menu__msg = scred_NLS_string('OSA_Install_Menu__msg') 
  145.     OSA_Dictionary_Menu__msg = scred_NLS_string('OSA_Dictionary_Menu__msg') 
  146.     OSA_Play_Menu__msg = scred_NLS_string('OSA_Play_Menu__msg') 
  147.     OSA_Stop_Menu__msg = scred_NLS_string('OSA_Stop_Menu__msg') 
  148.     OSA_Record_Menu__msg = scred_NLS_string('OSA_Record_Menu__msg') 
  149.     OSA_Lang_Menu__msg = scred_NLS_string('OSA_Lang_Menu__msg') 
  150.     OSA_synt_chk_Menu__msg = scred_NLS_string('OSA_synt_chk_Menu__msg') 
  151.     OSA_Show_Results_Menu__msg = scred_NLS_string('OSA_Show_Results_Menu__msg') 
  152.  
  153. ;; and add EPM special chars for the menubar help messages ...
  154.     OSA_barp__msg = \1||scred_NLS_string('OSA_barp__msg') 
  155.     OSA_Compile_menuP__msg = \1||scred_NLS_string('OSA_Compile_menuP__msg') 
  156.     OSA_Dictionary_menuP__msg = \1||scred_NLS_string('OSA_Dictionary_menuP__msg') 
  157.     OSA_Play_menuP__msg = \1||scred_NLS_string('OSA_Play_menuP__msg') 
  158.     OSA_Stop_menuP__msg = \1||scred_NLS_string('OSA_Stop_menuP__msg') 
  159.     OSA_Record_menuP__msg = \1||scred_NLS_string('OSA_Record_menuP__msg') 
  160.     OSA_Lang_menuP__msg = \1||scred_NLS_string('OSA_Lang_menuP__msg') 
  161.     OSA_synt_chk_menuP__msg = \1||scred_NLS_string('OSA_synt_chk_menuP__msg') 
  162.     OSA_Show_Results_menuP__msg = \1||scred_NLS_string('OSA_Show_Results_menuP__msg') 
  163.  
  164.     Scred_file_erase_warning = scred_NLS_string('Scred_file_erase_warning') 
  165.     Scred_file_erase_warning2 = scred_NLS_string('Scred_file_erase_warning2') 
  166.  
  167.     Script_Editor_EPM_title = scred_NLS_string('Script_Editor_EPM_title')
  168.     Default_Script_Comp_name = scred_NLS_string('Default_Script_Comp_name')
  169.  
  170.     Scred_Play_toolbar_title = scred_NLS_string('Scred_Play_toolbar_title')
  171.     Scred_Stop_toolbar_title = scred_NLS_string('Scred_Stop_toolbar_title')
  172.     Scred_Record_toolbar_title = scred_NLS_string('Scred_Record_toolbar_title')
  173.     Scred_synt_chk_toolbar_title = scred_NLS_string('Scred_synt_chk_toolbar_title')
  174.     Scred_Script_lang_toolbar_title_head = scred_NLS_string('Scred_Script_lang_toolbar_title_head')
  175.     Scred_Recording_statusline_title = scred_NLS_string('Scred_Recording_statusline_title')
  176.     Scred_Recording_suspended_statusline_title = scred_NLS_string('Scred_Recording_suspended_statusline_title')
  177.  
  178.   OSA_language = Default_Script_Comp_name  ---
  179.  
  180. ;; now initialize the dll:
  181. ;;sayerror 'window = ' getpminfo(EPMINFO_EDITCLIENT) ' ...'
  182.   log_file_name0 = LOG_FILE_NAME||\0
  183.   initretc = dynalink32('scredrec','SCREDREC_EPM_Init',
  184.                                 gethwndc(EPMINFO_EDITCLIENT) ||
  185.                                 atol(DO_AE_INIT) || 
  186.                                 address(log_file_name0), 2)
  187.  
  188.   if initretc <> 0 then
  189.      sayerror scred_NLS_string('Scred_EPM_Init_err_msg')|| initretc || '.'
  190.   endif
  191.  
  192.   len = dynalink32('scredrec','get_comp_name_length',  0, 2)
  193.   if len = 0 then
  194.      sayerror scred_NLS_string('Scred_EPM_comp_name_missing_msg')
  195.   else
  196.      bufadr = dynalink32('scredrec','get_comp_name',  0, 2)
  197.      if bufadr = 0 then
  198.         sayerror scred_NLS_string('Scred_EPM_comp_name_inaccessible_msg')
  199.      else
  200.         OSA_language = oldpeek32(bufadr,len)
  201. ;;        sayerror scred_NLS_string('Scred_EPM_comp_name_msg') || OSA_language || ' ...'
  202.      endif
  203.   endif
  204.  
  205.   len = dynalink32('scredrec','get_temp_file_name_length',  0, 2)
  206.   if len = 0 then
  207.      sayerror scred_NLS_string('Scred_EPM_temp_file_name_missing_msg')
  208.   else
  209.      bufadr = dynalink32('scredrec','get_temp_file_name',  0, 2)
  210.      if bufadr = 0 then
  211.         sayerror scred_NLS_string('Scred_EPM_temp_file_name_inaccessible_msg')
  212.      else
  213.         tmp_fn = oldpeek32(bufadr,len)
  214. ;;        sayerror scred_NLS_string('Scred_EPM_temp_file_name_msg') || tmp_fn || ' ...'
  215.      endif
  216.   endif
  217.  
  218.   menuname = 'default'
  219. ;;;   deletemenu menuname, 1, 0, 1             -- Delete the file menu
  220. ;;;   buildsubmenu menuname, 1, FILE_BAR__MSG, FILE_BARP__MSG, 0 , mpfrom2short(HP_FILE, 0)
  221. ;;;     buildmenuitem menuname, 1, 198, NEW_MENU__MSG,            'NEW'NEW_MENUP__MSG,     0, mpfrom2short(HP_FILE_NEW, 0)
  222. ;;;     buildmenuitem menuname, 1, 199, OPEN_NEW_MENU__MSG,       'OPEN'OPEN_NEW_MENUP__MSG,     0, mpfrom2short(HP_FILE_OPEN_NEW, 0)
  223. ;     buildmenuitem menuname, 1, 200, OPEN_MENU__MSG\9 || CTRL_KEY__MSG'+O', 'OPENDLG'OPEN_MENUP__MSG, 0, mpfrom2short(HP_FILE_OPEN, 0)
  224. ;;;     buildmenuitem menuname, 1, 200, OPEN_MENU__MSG\9 || CTRL_KEY__MSG'+O', 'OSA_load_new'ADD_MENUP__MSG, 0, mpfrom2short(HP_FILE_OPEN, 0)
  225. ;;;     buildmenuitem menuname, 1, 201, GET_MENU__MSG,            'OPENDLG GET'GET_MENUP__MSG,      0, mpfrom2short(HP_FILE_GET , 0)
  226. ;     buildmenuitem menuname, 1, 202, ADD_MENU__MSG\9'Ctrl+O', 'OPENDLG EDIT'ADD_MENUP__MSG,     0, mpfrom2short(HP_FILE_EDIT, 0)
  227. ;    buildmenuitem menuname, 1, 202, ADD_MENU__MSG\9'F8', 'osa_load_new'ADD_MENUP__MSG,     0, mpfrom2short(HP_FILE_EDIT, 0)
  228.        buildmenuitem menuname, 1, 102, SAMEWIN_MENU__MSG\9'F8', 'osa_load_new'ADD_MENUP__MSG,     0, mpfrom2short(HP_FILE_SAMEWIN, 0)
  229. ;;;     buildmenuitem menuname, 1, 203, \0,                          '',                 4, 0
  230. ;;;     buildmenuitem menuname, 1, 204, RENAME_MENU__MSG\9'F7',   'rename'RENAME_MENUP__MSG,0, mpfrom2short(HP_FILE_NAME, 0)
  231. ;;;     buildmenuitem menuname, 1, 205, \0,                          '',                 4, 0
  232. ;;;     buildmenuitem menuname, 1, 210, SAVE_MENU__MSG\9'F2',     'SAVE'SAVE_MENUP__MSG,             0, mpfrom2short(HP_FILE_SAVE, 0)
  233. ;;; compile if EVERSION >= '5.21'
  234. ;;;     buildmenuitem menuname, 1, 211, SAVEAS_MENU__MSG,         'SAVEAS_DLG'SAVEAS_MENUP__MSG, 0, mpfrom2short(HP_FILE_SAVEAS, 0)
  235. ;;;compile endif
  236. ;;;     buildmenuitem menuname, 1, 212, SAVECLOSE_MENU__MSG\9'F4',     'FILE'FILE_MENUP__MSG,        0, mpfrom2short(HP_FILE_FILE, 0)
  237. ;;;     buildmenuitem menuname, 1, 213, QUIT_MENU__MSG\9'F3',     'QUIT'QUIT_MENUP__MSG,             0, mpfrom2short(HP_FILE_QUIT, 0)
  238. ;;;     buildmenuitem menuname, 1, 214, \0,                           '',                 4, 0
  239. ;;; compile if EVERSION < '5.51'
  240. ;;;     buildmenuitem menuname, 1, 215, PRT_FILE_MENU__MSG,       'xcom save' default_printer()PRT_FILE_MENUP__MSG,   0, mpfrom2short(HP_FILE_PRINT, 0)
  241. ;;; compile else
  242. ;;;     buildmenuitem menuname, 1, 215, PRT_FILE_MENU__MSG,       'xcom save /s /ne' default_printer()PRT_FILE_MENUP__MSG,   0, mpfrom2short(HP_FILE_PRINT, 0)
  243. ;;; compile endif
  244.  
  245.    deletemenu menuname, HELP_MENU_ID, 0, 0             -- Delete the help menu
  246.  osa_menu_ID = HELP_MENU_ID + 4
  247.    buildsubmenu menuname, osa_menu_ID, OSA_bar__msg, OSA_barp__msg, 0 , mpfrom2short(HP_OSA,0)
  248.      buildmenuitem menuname, osa_menu_ID, 800, OSA_Compile_Menu__msg\9'F6', 'osa_compile'OSA_Compile_menuP__msg, 0, mpfrom2short(HP_OSA_Compile,0)
  249.      buildmenuitem menuname, osa_menu_ID, 805, \0,                          '',                 4, 0
  250. ;;;     buildmenuitem menuname, osa_menu_ID, 810, OSA_Install_Menu__msg, 'osa_install', 0, mpfrom2short(HP_OSA_Install,0)
  251. ;;;     buildmenuitem menuname, osa_menu_ID, 815, \0,                          '',                 4, 0
  252.      buildmenuitem menuname, osa_menu_ID, 820, OSA_Dictionary_Menu__msg\9'F12', 'osa_dictionary'OSA_Dictionary_menuP__msg, 0, mpfrom2short(HP_OSA_Dictionary,0)
  253.      buildmenuitem menuname, osa_menu_ID, 825, \0,                          '',                 4, 0
  254.      buildmenuitem menuname, osa_menu_ID, 830, OSA_Lang_Menu__msg, OSA_Lang_menuP__msg, 0, mpfrom2short(HP_OSA_Language,0)
  255.      buildmenuitem menuname, osa_menu_ID, 835, \0,                          '',                 4, 0
  256.      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)
  257.      buildmenuitem menuname, osa_menu_ID, 845, \0,                          '',                 4, 0
  258.      buildmenuitem menuname, osa_menu_ID, 850, OSA_Play_Menu__msg,  'do_push_play_button'OSA_Play_menuP__msg, 0, mpfrom2short(HP_OSA_Play,0)
  259.      buildmenuitem menuname, osa_menu_ID, 852, \0,                          '',                 4, 0
  260.      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)
  261.      buildmenuitem menuname, osa_menu_ID, 855, \0,                          '',                 4, 0
  262.      buildmenuitem menuname, osa_menu_ID, 860, OSA_Stop_Menu__msg,  'do_push_stop_button'OSA_Stop_menuP__msg, 0, mpfrom2short(HP_OSA_StopRec,0)
  263.      buildmenuitem menuname, osa_menu_ID, 865, \0,                          '',                 4, 0
  264.      buildmenuitem menuname, osa_menu_ID, 870, OSA_Record_Menu__msg, 'do_push_record_button'OSA_Record_menuP__msg, 0, mpfrom2short(HP_OSA_StartRec,0)
  265.  
  266. new_HELP_MENU_ID = HELP_MENU_ID + 10;
  267. ;   stolen from stdmenu.e
  268.    buildsubmenu menuname, new_HELP_MENU_ID, HELP_BAR__MSG, 'help'HELP_BARP__MSG, /* 512 */  0, mpfrom2short(HP_HELP, 0)
  269.      buildmenuitem menuname, new_HELP_MENU_ID, 600, HELP_INDEX_MENU__MSG,   'helpmenu 10'/*64044*/HELP_INDEX_MENUP__MSG,   0, mpfrom2short(HP_HELP_INDEX, 0)
  270.      buildmenuitem menuname, new_HELP_MENU_ID, 601, EXT_HELP_MENU__MSG,     'helpmenu 4000'EXT_HELP_MENUP__MSG, 0, mpfrom2short(HP_HELP_EXTENDED, 0)
  271.      buildmenuitem menuname, new_HELP_MENU_ID, 602, HELP_HELP_MENU__MSG,    'helpmenu 64027'HELP_HELP_MENUP__MSG,    0, mpfrom2short(HP_HELP_HELP, 0)
  272.      buildmenuitem menuname, new_HELP_MENU_ID, 603, KEYS_HELP_MENU__MSG,    'helpmenu 1000'KEYS_HELP_MENUP__MSG, 0, mpfrom2short(HP_HELP_KEYS, 0)
  273.      buildmenuitem menuname, new_HELP_MENU_ID, 604, COMMANDS_HELP_MENU__MSG,'helpmenu 2000'COMMANDS_HELP_MENUP__MSG, 0, mpfrom2short(HP_HELP_COMMANDS, 0)
  274.      buildmenuitem menuname, new_HELP_MENU_ID, 605, \0,           '',                        4, 0
  275.      buildmenuitem menuname, new_HELP_MENU_ID, 606, HELP_BROWSER_MENU__MSG, 'help'HELP_BROWSER_MENUP__MSG,    0, mpfrom2short(HP_HELP_BROWSE, 0)
  276.      buildmenuitem menuname, new_HELP_MENU_ID, 607, \0,           '',                        4, 0
  277. compile if 0
  278.      buildmenuitem menuname, new_HELP_MENU_ID, 608, '#211'||(3-(screenxysize('X')>1000)), 'IBMmsg'HELP_PROD_MENUP__MSG, 2, mpfrom2short(HP_HELP_IBM, 0)
  279.                          -- Resource # 2112 or 2113 in ERES.DLL
  280. compile else
  281.      buildmenuitem menuname, new_HELP_MENU_ID, 608, HELP_PROD_MENU__MSG, 'IBMmsg'HELP_PROD_MENUP__MSG, 0, mpfrom2short(HP_HELP_PROD, 0)
  282. compile endif
  283. compile if SUPPORT_USERS_GUIDE | SUPPORT_TECHREF
  284.      buildmenuitem menuname, new_HELP_MENU_ID, 610, \0,           '',                        4, 0
  285.  compile if SUPPORT_USERS_GUIDE
  286.      buildmenuitem menuname, new_HELP_MENU_ID, 620, USERS_GUIDE_MENU__MSG,   USERS_GUIDE_MENUP__MSG, 17+64, mpfrom2short(HP_HELP_USERS_GUIDE, 0)
  287.        buildmenuitem menuname, new_HELP_MENU_ID, 621, VIEW_USERS_MENU__MSG,  'view epmusers'VIEW_USERS_MENUP__MSG, 0, mpfrom2short(HP_HELP_USERS_GUIDE, 0)
  288.        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)
  289.        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)
  290.  compile endif
  291.  compile if SUPPORT_TECHREF
  292.      buildmenuitem menuname, new_HELP_MENU_ID, 630, TECHREF_MENU__MSG,   TECHREF_MENUP__MSG, 17+64, mpfrom2short(HP_HELP_TECHREF, 0)
  293.        buildmenuitem menuname, new_HELP_MENU_ID, 631, VIEW_TECHREF_MENU__MSG,  'view epmtech'VIEW_TECHREF_MENUP__MSG, 0, mpfrom2short(HP_HELP_TECHREF, 0)
  294.        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)
  295.  compile endif
  296. compile endif
  297.  
  298.  showmenu menuname
  299.  
  300.       'toggleframe 4 0'     -- remove the rings from the upper right corner ...
  301.  
  302.       menu = 'Toolbar'
  303.       deletemenu menu
  304.  
  305.   call set_OSA_status()
  306.  
  307.   .titletext = Script_Editor_EPM_title .filename
  308.  
  309. ;  fn = .filename
  310. ;  if fn <> UNNAMED_FILE_NAME then
  311. ;    'xcom e /n'
  312. ;    'postme edit' fn
  313. ;  endif
  314.  
  315.   return
  316.  
  317. defc do_show_results =
  318. ;;  sayerror scred_NLS_string('Scred_EPM_trying_async_action_msg') || SCREDREC_show_results || ' ...'
  319.   title = scred_NLS_string('Scred_EPM_Results_title')||\0
  320.   retc = dynalink32('scredrec','Try_async_action',
  321.                                atol(SCREDREC_show_results) || address(title), 2)
  322.  
  323.   return
  324.  
  325. defc push_play_button =
  326.    universal OSA_Play_menuP__msg
  327.    parse arg action_letter parms
  328.  if action_letter = 'S' then       -- button selected
  329.     'do_push_play_button' parms
  330.  elseif action_letter = 'H' then       -- help asked
  331.     'helpmenu' HP_OSA_Play
  332.  elseif action_letter = 'I' then       -- button initialized
  333.     sayerror substr(OSA_Play_menuP__msg,2)
  334.  endif
  335.  
  336. defc do_push_play_button =
  337.    universal activeucmenu, toolbar_loaded
  338.    universal OSA_play, OSA_record
  339.    universal OSA_language
  340.    universal stable_bar
  341.    universal source_version, compiled_source_version, temp_source_version
  342.    universal tmp_fn, source_only
  343.    universal scredrec_modified
  344.    universal scredrec_last_modified
  345.  
  346.   if OSA_play = OSA_on then
  347.      return
  348.   endif
  349. ;; update the source if the file is changed ...
  350.   if scredrec_last_modified <> .modify or source_version < compiled_source_version then
  351.      --- save source into a temp file ...
  352.      temp_source_version = source_version + 2
  353.      tmp = .modify
  354.      fn = .filename
  355.      'xcom save ' tmp_fn
  356.      tmp_fn0 = tmp_fn||\0
  357.      .filename = fn
  358.      .modify = tmp
  359.      retc = dynalink32('scredrec','Update_Source',
  360.                               address(tmp_fn0) || atol(0), 2)          -- don't remove the file
  361.      if retc <> 0 then
  362.          sayerror scred_NLS_string('Scred_EPM_Update_source_msg') || retc || ' ...'
  363.          temp_source_version = 0
  364.      else
  365.           source_version = temp_source_version - 1
  366.           scredrec_last_modified = .modify
  367.           source_only = OSA_on
  368.           scredrec_modified = 1
  369.      endif
  370.   endif
  371.  
  372. ;;  sayerror scred_NLS_string('Scred_EPM_trying_async_action_msg') || SCREDREC_play || ' ...'
  373.   retc = dynalink32('scredrec','Try_async_action',
  374.                                atol(SCREDREC_play) || NULL, 2)
  375.  
  376.   OSA_play = OSA_on
  377.  
  378.   call set_OSA_status()
  379.  
  380.   return
  381.  
  382. defproc finish_push_play_button(msg_value)
  383.    universal activeucmenu, toolbar_loaded
  384.    universal OSA_play, OSA_record
  385.    universal OSA_language
  386.    universal stable_bar
  387.  
  388.   if msg_value = SCREDREC_failure then
  389.      sayerror scred_NLS_string('Scred_EPM_Play_err_msg')
  390.   endif
  391.  
  392.   OSA_play = OSA_off
  393.  
  394.   call set_OSA_status()
  395.  
  396.   return
  397.  
  398. defc push_record_button =
  399.    universal OSA_Record_menuP__msg
  400.    parse arg action_letter parms
  401.  if action_letter = 'S' then       -- button selected
  402.     'do_push_record_button' parms
  403.  elseif action_letter = 'H' then       -- help asked
  404.     'helpmenu' HP_OSA_StartRec
  405.  elseif action_letter = 'I' then       -- button initialized
  406.     sayerror substr(OSA_Record_menuP__msg,2)
  407.  endif
  408.  
  409. defc do_push_record_button =
  410.    universal activeucmenu, toolbar_loaded
  411.    universal OSA_play, OSA_record
  412.    universal OSA_language
  413.    universal stable_bar
  414. ;;  Recording disabled ...
  415.    sayerror scred_NLS_string('Scred_EPM_Recording_disabled_msg')
  416.    return
  417.   if OSA_record <> OSA_suspended and OSA_record <> OSA_off then
  418.      return
  419.   endif
  420.   OSA_record = OSA_started
  421. ;;  sayerror scred_NLS_string('Scred_EPM_trying_async_action_msg') || SCREDREC_record || ' ...'
  422.   retc = dynalink32('scredrec','Try_async_action',
  423.                                atol(SCREDREC_record) || NULL, 2)
  424. ;;  if retc <> 0 then
  425. ;;     sayerror 'error initializing Recording ... retc = ' retc '.'
  426. ;;     OSA_record = OSA_off
  427. ;;  endif
  428.  
  429.   return
  430.  
  431. defproc finish_push_record_button(msg_value)
  432.    universal activeucmenu, toolbar_loaded
  433.    universal OSA_play, OSA_record
  434.    universal OSA_language
  435.    universal stable_bar
  436.  
  437.   if msg_value = SCREDREC_failure then
  438.      sayerror scred_NLS_string('Scred_EPM_StartRec_err_msg')
  439.      OSA_record = OSA_off
  440.   else
  441.      OSA_record = OSA_on
  442.   endif
  443.  
  444.   call set_OSA_status()
  445.  
  446.   return
  447.  
  448. defc push_stop_button =
  449.    universal OSA_Stop_menuP__msg
  450.    parse arg action_letter parms
  451.  if action_letter = 'S' then       -- button selected
  452.     'do_push_stop_button' parms
  453.  elseif action_letter = 'H' then       -- help asked
  454.     'helpmenu' HP_OSA_StopRec
  455.  elseif action_letter = 'I' then       -- button initialized
  456.     sayerror substr(OSA_Stop_menuP__msg,2)
  457.  endif
  458.  
  459. defc do_push_stop_button =
  460.    universal activeucmenu, toolbar_loaded
  461.    universal OSA_play, OSA_record
  462.    universal OSA_language
  463.    universal stable_bar
  464.   if OSA_play <> OSA_on and OSA_record <> OSA_on then
  465.     return
  466.   endif
  467. ;  sayerror 'OSA language = '||OSA_language || ' ...'
  468. ; this doesn't work yet - we cannot stop OSAExecute ...
  469. ;  if OSA_play = OSA_on then
  470. ;     OSA_play = OSA_off
  471. ;  endif
  472.  
  473.   if OSA_record = OSA_on then
  474.     OSA_record = OSA_dying
  475.   endif
  476. ;;    sayerror scred_NLS_string('Scred_EPM_trying_async_action_msg') || SCREDREC_stop || ' ...'
  477.     retc = dynalink32('scredrec','Try_async_action',
  478.                                 atol(SCREDREC_stop) || NULL, 2)
  479. ;;    if retc <> 0 then
  480. ;;       sayerror 'error stopping Recording ... retc = ' retc '.'
  481. ;;       OSA_record = OSA_on
  482. ;;    endif
  483. ;;  endif
  484.  
  485.   call set_OSA_status()
  486.  
  487. defproc finish_stop_recording(msg_value)
  488.    universal activeucmenu, toolbar_loaded
  489.    universal OSA_play, OSA_record
  490.    universal OSA_language
  491.    universal stable_bar
  492.   if OSA_record <> OSA_dying then
  493.      return
  494.   endif
  495.   if msg_value = SCREDREC_failure then
  496.      sayerror scred_NLS_string('Scred_EPM_StopRec_err_msg')
  497.      OSA_record = OSA_on
  498.   else
  499.      OSA_record = OSA_suspended
  500.   endif
  501.  
  502.   call set_OSA_status()
  503.  
  504.   return
  505.  
  506. defc scred_synt_check =
  507.    universal OSA_synt_chk_menuP__msg
  508.    parse arg action_letter parms
  509.  if action_letter = 'S' then       -- button selected
  510.     'do_scred_synt_check' parms
  511.  elseif action_letter = 'H' then       -- help asked
  512.     'helpmenu' HP_OSA_SynCheck
  513.  elseif action_letter = 'I' then       -- button initialized
  514.     sayerror substr(OSA_synt_chk_menuP__msg,2)
  515.  endif
  516.  
  517. defc do_scred_synt_check =
  518.    universal activeucmenu, toolbar_loaded
  519.    universal OSA_synt_check
  520.    universal stable_bar
  521.   if OSA_synt_check = OSA_off then
  522.  
  523.     --- set syntax check on ...
  524.    sayerror scred_NLS_string('Scred_EPM_syn_chk_enabled_msg')
  525.    'toggle_parse 1 epmkwds.orx'
  526.    OSA_synt_check = OSA_on
  527.  
  528.   else
  529.    sayerror scred_NLS_string('Scred_EPM_syn_chk_disabled_msg')
  530.    'toggle_parse 0'
  531.    OSA_synt_check = OSA_off
  532.   endif
  533.  
  534.   if stable_bar = OSA_off then
  535.    call set_OSA_status()
  536.   endif
  537.  
  538. defc osa_compile=
  539.    universal source_version, compiled_source_version, temp_source_version
  540.    universal tmp_fn, source_only
  541.    universal scredrec_modified
  542.    universal scredrec_last_modified
  543.  
  544. ;;   scredrec_modified = 0
  545.     if temp_source_version <> 0 then
  546.       sayerror scred_NLS_string('Scred_EPM_Already_compiling_err_msg')
  547.       return 0
  548.     endif
  549.     -- temp source version is one more than the target compiled source version ...
  550.     temp_source_version = source_version +1
  551.     if scredrec_last_modified <> .modify or source_version < compiled_source_version then
  552.        --- save source into a temp file ...
  553.        temp_source_version = source_version + 2
  554.        tmp = .modify
  555.        fn = .filename
  556.        'xcom save ' tmp_fn
  557.        tmp_fn0 = tmp_fn||\0
  558.        .filename = fn
  559.        .modify = tmp
  560.        retc = dynalink32('scredrec','Update_Source',
  561.                                 address(tmp_fn0) || atol(0), 2)          -- don't remove the file
  562.        if retc <> 0 then
  563.            sayerror scred_NLS_string('Scred_EPM_Update_source_msg') || retc || ' ...'
  564.            temp_source_version = 0
  565.        else
  566.             source_version = temp_source_version - 1
  567.             scredrec_last_modified = .modify
  568.             source_only = OSA_on
  569.             scredrec_modified = 1
  570.        endif
  571.     endif
  572.     if temp_source_version > 0 then
  573. ;;      sayerror scred_NLS_string('Scred_EPM_trying_async_action_msg') || SCREDREC_compile || ' ...'
  574.       retc = dynalink32('scredrec','Try_async_action',
  575.                                   atol(SCREDREC_compile) || NULL, 2)
  576.     endif
  577.  
  578. defproc finish_compile(msg_value)
  579.    universal source_version, compiled_source_version, temp_source_version
  580.    universal tmp_fn
  581.    universal scredrec_modified
  582.    universal scredrec_last_modified
  583.   if msg_value = SCREDREC_failure then
  584.      sayerror scred_NLS_string('Scred_EPM_Compile_err_msg')
  585.   else
  586.      sayerror scred_NLS_string('Scred_EPM_Compile_success_msg')
  587.  
  588.      scredrec_modified = 1
  589.      source_only = OSA_off
  590.  
  591.      if temp_source_version <> 0 then
  592.         compiled_source_version = temp_source_version - 1
  593.      endif
  594.  
  595.   endif
  596.  
  597.   temp_source_version = 0
  598.  
  599. defc osa_install=
  600.  sayerror scred_NLS_string('Scred_EPM_install_not_implemented_msg')
  601.  
  602. defc osa_dictionary=
  603. ;; sayerror 'OSA dictionary opened ...'
  604.  -- first, find the list of AETEs ...
  605.  aete_list_len = dynalink32('scredrec','get_aete_list_length', , 2)
  606.  
  607. ;; sayerror 'len = ' aete_list_len
  608.  
  609.  if aete_list_len = 0 then    -- no applications???
  610. ;;    sayerror 'on the 1st call to OSAListApplications, list length = 0 ...'
  611.     return 0
  612.  endif
  613.  
  614.  aete_list = copies(\0,aete_list_len)
  615.  
  616.  len = atol(aete_list_len)
  617.  retc = dynalink32('scredrec','get_aete_list',
  618.                          address(aete_list) || address(len) , 2)
  619.  if retc<>0 then     -- no applications, or buffer too small???
  620. ;;    sayerror 'on the 2nd call to OSAListApplications, retc =' retc ' ...'
  621.     return 0
  622.  endif
  623.  
  624.  new_aete_list_len = ltoa(len,10)
  625. ;; sayerror 'new length is ' new_aete_list_len
  626.  
  627.  if new_aete_list_len<2 then     -- no applications??
  628.     return 0
  629.  endif
  630.  
  631.  if new_aete_list_len < aete_list_len then
  632.     aete_list = leftstr(aete_list,new_aete_list_len)
  633.  endif
  634.  
  635.  if rightstr(aete_list,1) <> \1 then
  636.     aete_list = aete_list || \1
  637.  endif
  638.  
  639.  aete_list = \1 || aete_list
  640.  
  641. ;; sayerror 'calling listbox ...'
  642.  aete = listbox(scred_NLS_string('Scred_EPM_Select_app_msg'), aete_list)
  643.  
  644.  if aete=='' then       -- didn't select any app
  645.     return 0
  646.  endif
  647.  
  648. ;; sayerror 'aete' aete 'selected ...'
  649.  
  650.  aete0 = aete||\0
  651.  retc = dynalink32('scredrec','show_aete',
  652.                          address(aete0) , 2)
  653.  if retc<>0  then     -- problems with Print ???
  654. ;;    sayerror 'on the call to show_aete, retc =' retc '...'
  655.     return 0
  656.  endif
  657.  
  658.  return
  659.  
  660. defc osa_load_new=
  661.    universal scredrec_modified
  662.    universal Scred_file_erase_warning, Scred_file_erase_warning2
  663.    if .modify>0 or scredrec_modified<>0 then 
  664.      res = winmessagebox(Scred_file_erase_warning, Scred_file_erase_warning2,
  665.                                   MB_OKCANCEL + MB_DEFBUTTON2)
  666.      if res <> MBID_OK then
  667.         return
  668.      endif
  669.    endif
  670.    'opendlg edit'
  671.  
  672. def f12='osa_dictionary'
  673.  
  674. def f6='osa_compile'
  675.  
  676. def f4=
  677.    universal scredrec_modified
  678.    if .modify > 0 or scredrec_modified <> 0 then
  679.       'File'
  680.    else
  681.       'Quit'
  682.    endif
  683.  
  684. ;def f5,c_O=
  685. ;  'opendlg'
  686.  
  687. def f8=
  688.   'osa_load_new'
  689. ;   sayerror NO_RING__MSG
  690. ;   return
  691.  
  692. ;; old peek32 function, without the offset field; the interface was changed in EPM 6.03 ...
  693. defproc oldpeek32(bufaddr,len)
  694. compile if EVERSION > 6.025
  695.       return peek32(bufaddr,0,len)
  696. compile else
  697.       return peek32(bufaddr,len)
  698. compile endif
  699.  
  700. ;; for debug only: sometimes EPM loses its file id ...
  701. defc sayfileid
  702.    getfileid id
  703.    sayerror 'file id is '|| id ||' ('||length(id)||' chars) now ...'
  704.  
  705. ;; keep only one file in the ring
  706. ;;defload
  707. defselect
  708.   'postme keep_one_file_in_the_ring'
  709.  
  710. defc keep_one_file_in_the_ring
  711.   universal Script_Editor_EPM_title
  712. ;; sayerror "keeping one file in the ring ..."
  713.    getfileid startid
  714. ;; sayerror 'startid = ' startid
  715. ;; sometimes EPM forgets its fileid; the following lines try to recover it ...
  716.    if startid = '' then
  717.      do i=1 to 5
  718.        nextfile
  719.        getfileid nextid
  720.        if nextid <> '' then
  721. ;; sayerror "recovering id =" nextid||", i="||i"."
  722.          refresh
  723.          return
  724.        endif
  725.      end
  726.      nextfile
  727.      refresh
  728.      return
  729.    endif
  730. ;    return
  731. ;; sayerror filesinring() 'files in ring ...'
  732.    if filesinring() < 2 then
  733.      return
  734.    endif
  735.  -- temp fix for the toolbar commands ...
  736. ;;   if rightstr(.filename,11) == 'actions.lst' then
  737. ;;      return
  738. ;;   endif
  739.    n = filesinring()-1
  740.    do i=1 to n
  741.     nextfile
  742.     getfileid nextid
  743.     if startid <> nextid then
  744.       .modify = 0
  745.       'xcom quit'
  746.     endif
  747.    enddo
  748.  
  749.   activatefile startid
  750.   .titletext = Script_Editor_EPM_title .filename
  751.  
  752.    refresh
  753.    return
  754.  
  755. ; the save command is rewritten in order to read the right source from the script file ...
  756. defc s,save=
  757. universal default_save_options
  758.    universal source_version, compiled_source_version, temp_source_version
  759.    universal tmp_fn, source_only
  760.    universal scredrec_modified
  761.    universal scredrec_last_modified
  762.    universal Script_Editor_EPM_title
  763.    name=arg(1)
  764.    call parse_leading_options(name,options)
  765. ;;   sayerror 'saving a file, name = ' name ', options = ' options '.'
  766.    options = default_save_options options
  767.    save_as = 0
  768.       name=.filename
  769.    if name='' | name=UNNAMED_FILE_NAME then
  770.          result = saveas_dlg(name, type)
  771.          if result then return result; endif            -- cancel
  772.          if name<>.filename then
  773. ;;            sayerror 'new name = ' name ' ...'
  774.             .filename = name
  775.          endif
  776. ;;         'name' name
  777. ;;         if not rc then
  778. ;;            name=.filename
  779. ;;            save_as = 1
  780. ;;         endif
  781.    else
  782.       call parse_filename(name,.filename)
  783.    endif
  784.    if leftstr(name,1) = '"' then     --- quoted string ...
  785.       name = rightstr(name, length(name) -1)
  786.       if rightstr(name,1) = '"' then     --- quoted string ...
  787.          name = leftstr(name, length(name) -1)
  788.       endif
  789.    endif
  790. ;;   sayerror 'last name = ' name ' ...'
  791.  
  792. ;;  if .modify > 0 then
  793.     if scredrec_last_modified <> .modify then
  794.        --- save source into a temp file ...
  795. ;;       sayerror 'save source into a temp file ' tmp_fn ' ...'
  796.        tmp = .modify
  797.        fn = .filename
  798.        'xcom save ' tmp_fn
  799.        tmp_fn0 = tmp_fn||\0
  800.        .filename = fn
  801.        .modify = tmp
  802.        retc = dynalink32('scredrec','Update_Source',
  803.                                 address(tmp_fn0) || atol(0), 2)          -- don't remove the file
  804.        if retc <> 0 then
  805.            sayerror scred_NLS_string('Scred_EPM_Update_source_msg') || retc || ' ...'
  806.        else
  807.             source_version = tmp
  808.             source_only = OSA_on
  809.             source_version = source_version + 1
  810.             scredrec_last_modified = .modify
  811.             scredrec_modified = 1
  812.        endif
  813.     endif
  814.  
  815. ;;; should it be compiled now??
  816.  
  817.     name0 = name || \0
  818.     retc = dynalink32('scredrec','Save_the_file', address(name0), 2)
  819.     if retc <> 0 then
  820.         sayerror scred_NLS_string('Scred_EPM_Save_the_file_msg') || retc || ' ...'
  821.     else
  822.         .modify = 0
  823.         scredrec_last_modified = 0
  824.         scredrec_modified = 0
  825.     endif
  826.  
  827.   .titletext = Script_Editor_EPM_title .filename
  828.  
  829.  
  830. defc File=
  831.    'save' arg(1)
  832.    'Quit'
  833.  
  834. ; the edit command is rewritten in order to read the right source from the script file ...
  835. defc e,ed,edit,epm=
  836. universal default_edit_options
  837.    universal source_version, compiled_source_version, temp_source_version
  838.    universal tmp_fn, source_only
  839.    universal scredrec_modified
  840.    universal scredrec_last_modified
  841.    universal OSA_synt_check
  842.    universal Script_Editor_EPM_title
  843.  
  844.    args=strip(arg(1))
  845.  
  846.    source_update = 1            --- default
  847.  
  848.    options=default_edit_options
  849.    do while leftstr(args,1) = "/"
  850.       parse value args with opt args
  851.       opt = upcase(opt)
  852.       if opt = "/SCRED_GET"  then
  853.         source_update = 0
  854.       else
  855.         options = options opt
  856.       endif
  857.    enddo
  858.  
  859.    if args = '=' then
  860.      args = .filename
  861.    endif
  862.  
  863.    if leftstr(args,1) = '"' then     --- quoted string ...
  864.       firstfile = rightstr(args, length(args) -1)       /* left quote removed ... */
  865.       p = pos('"',firstfile)
  866.       if p > 0 then
  867.          firstfile = leftstr(firstfile, p-1)            /* right quote and the tail removed ... */
  868.       endif
  869.    else
  870.      parse value args with firstfile .
  871.    endif
  872.  
  873. ;;   sayerror 'files loaded: 1st file is 'firstfile' ...'
  874.    -- temp fix for the toolbar commands ...
  875.    if rightstr(firstfile,11) == 'actions.lst' then
  876.       'xcom e' arg(1)
  877.       return 0
  878.    endif
  879.    if firstfile='' or firstfile = '=' then   /* 'edit' by itself goes to the next file */
  880.       return 0
  881.    else
  882.       secondfile = copies(\0,257)
  883.       firstfile0 = firstfile||\0
  884.       retc = dynalink32('scredrec','Read_the_file', address(firstfile0) ||
  885.                                 address(secondfile) ||
  886.                                 atol(source_update) , 2)
  887.       if retc = SCREDREC_file_not_found and 
  888.          qfilemode(fistfile,junkattr) = 2 then    -- file name is OK, but the file doesn't exist
  889.            retc2 = dynalink32('scredrec','make_empty_file',0,2)
  890.            if retc2 = 0 then
  891. ;;             sayerror 'loading empty file' firstfile
  892.              'xcom e /n' options
  893.               source_only = OSA_on
  894.               source_version = 1
  895.              .filename = firstfile
  896.              compiled_source_version = 0
  897.              temp_source_version = 0
  898.              scredrec_modified = 0
  899.              scredrec_last_modified = 0
  900.              if OSA_synt_check = OSA_off then
  901.                    'toggle_parse 0'
  902.              else
  903.                    'toggle_parse 1 epmkwds.orx'
  904.              endif                                                         
  905.              if source_update > 0 then
  906.                'postme keep_one_file_in_the_ring'
  907.              endif                                                         
  908.  
  909.              return 0
  910.            endif
  911.  
  912.       endif
  913.       if retc <> 0 then
  914.          sayerror scred_NLS_string('Scred_EPM_Load_file_err_msg') || firstfile || ',  ... retc = ' || retc || '.'
  915.          return 0
  916.       endif
  917.       len = pos(\0,secondfile) -1
  918.       if len > 0 then
  919.          fn = leftstr(secondfile,len)
  920.          if fn = firstfile then
  921. ;;            sayerror 'loading source file ...'
  922.             source_only = OSA_on
  923.             source_version = 1
  924.          else
  925. ;;            sayerror 'loading compiled script file, temp file is ' fn ' ...'
  926.             source_only = OSA_off
  927.             source_version = 0
  928.          endif
  929. ;;         'xcom e /d' options fn         -- reload if needed ...
  930.          loadfile(fn,"/D "options)
  931.          .filename = firstfile
  932.          compiled_source_version = 0
  933.          temp_source_version = 0
  934.          scredrec_modified = 0
  935.          scredrec_last_modified = 0
  936.          if OSA_synt_check = OSA_off then
  937.                'toggle_parse 0'
  938.          else
  939.                'toggle_parse 1 epmkwds.orx'
  940.          endif
  941.          if source_update > 0 then
  942.            'postme keep_one_file_in_the_ring'
  943.          endif
  944.       else
  945.          sayerror scred_NLS_string('Scred_EPM_Load_file_err_msg') || firstfile || ' ...'
  946.     endif
  947.  
  948.   endif
  949.  
  950.   .titletext = Script_Editor_EPM_title .filename
  951.  
  952.  
  953. ; use the status line instead of toolbar to show the state of SCREDREC ...
  954. defproc make_stable_bar()
  955.    universal stable_bar
  956.    universal Scred_Stop_toolbar_title
  957.    stable_bar = OSA_on
  958. ;   sayerror 'stable_bar set ...'
  959.    --- set the toolbar ...
  960.    menu = 'Toolbar'
  961.    buildsubmenu menu ,  2, "#"||Scred_Stop_toolbar_title||"#scrstop.bmp#push_stop_button", '', 0, 0
  962.   buildsubmenu menu ,  4, "##scrempty.bmp#",'', 0, 0
  963.    showmenu menu, 3
  964.    toolbar_loaded = 'scredrec'
  965.    refresh
  966.  
  967.    call set_OSA_status()
  968.  
  969. defproc set_OSA_status()
  970.    universal activeucmenu, toolbar_loaded
  971.    universal OSA_play, OSA_record, OSA_synt_check
  972.    universal OSA_language
  973.    universal stable_bar
  974.  
  975.    universal Scred_Play_toolbar_title
  976.    universal Scred_Stop_toolbar_title
  977.    universal Scred_Record_toolbar_title
  978.    universal Scred_synt_chk_toolbar_title
  979.    universal Scred_Script_lang_toolbar_title_head
  980.    universal Scred_Recording_statusline_title
  981.    universal Scred_Recording_suspended_statusline_title
  982.  
  983. ;;   sayerror 'OSA_play = ' OSA_play ', OSA_record = ' OSA_record ', OSA_synt_check = ' OSA_synt_check ' ...'
  984.  
  985.    if stable_bar = OSA_off then
  986.      -- change the toolbar ...
  987.      menu = 'Toolbar'
  988.      activeucmenu = menu
  989.      stop_enabled = OSA_off
  990.      if OSA_play = OSA_off then
  991.          buildsubmenu menu ,  1, "#"||Scred_Play_toolbar_title||"#scrplay.bmp#push_play_button", '', 0, mpfrom2short(HP_OSA_Play,0)
  992.      else
  993.          buildsubmenu menu ,  1, "#"||Scred_Play_toolbar_title||"#scrplayp.bmp#push_play_button", '', 0, mpfrom2short(HP_OSA_Play,0)
  994.          stop_enabled = OSA_on
  995.      endif
  996.      if OSA_record = OSA_on then
  997.          stop_enabled = OSA_on
  998.      endif
  999.      if stop_enabled = OSA_on then
  1000.          buildsubmenu menu ,  2, "#"||Scred_Stop_toolbar_title||"#scrstop.bmp#push_stop_button", '', 0, mpfrom2short(HP_OSA_StopRec,0)
  1001.      else
  1002.          buildsubmenu menu ,  2, "#"||Scred_Stop_toolbar_title||"#scrstopp.bmp#push_stop_button", '', 0, mpfrom2short(HP_OSA_StopRec,0)
  1003.      endif
  1004.      if OSA_record = OSA_on or OSA_record = OSA_dying then
  1005.          buildsubmenu menu ,  3, "#"||Scred_Record_toolbar_title||"#scr_recp.bmp#push_record_button", '', 0, mpfrom2short(HP_OSA_StartRec,0)
  1006.          buildsubmenu menu ,  4, "#"||Scred_Script_lang_toolbar_title_head||OSA_language||"#scremptr.bmp#",'', 0, 0
  1007.      else       -- off, suspended, or started
  1008.          buildsubmenu menu ,  3, "#"||Scred_Record_toolbar_title||"#scr_rec.bmp#push_record_button", '', 0, mpfrom2short(HP_OSA_StartRec,0)
  1009.          buildsubmenu menu ,  4, "#"||Scred_Script_lang_toolbar_title_head||OSA_language||"#scrempty.bmp#",'', 0, 0
  1010.      endif
  1011.      if OSA_synt_check = OSA_on then
  1012.          buildsubmenu menu , 28, "#"||Scred_synt_chk_toolbar_title||"#scrschkp.bmp#scred_synt_check", '',0, mpfrom2short(HP_OSA_SynCheck,0)
  1013.      else
  1014.          buildsubmenu menu , 28, "#"||Scred_synt_chk_toolbar_title||"#scrschk.bmp#scred_synt_check", '',0, mpfrom2short(HP_OSA_SynCheck,0)
  1015.      endif
  1016.  
  1017.      refresh
  1018.  
  1019.      showmenu menu, 3
  1020.      toolbar_loaded = 'scredrec'
  1021.  
  1022.    else
  1023.      -- change the status line ...
  1024.      statl = STATUS_TEMPLATE__MSG||OSA_language
  1025.  
  1026.      rec=""
  1027.      if OSA_record = OSA_on then
  1028.         rec=Scred_Recording_statusline_title
  1029.      endif
  1030.      if OSA_record = OSA_suspended then
  1031.         rec=Scred_Recording_suspended_statusline_title
  1032.      endif
  1033.  
  1034.      statl = statl||rec
  1035.  
  1036.      'setstatusline' statl
  1037.    endif
  1038.  
  1039.   return
  1040.  
  1041. ;; get an info msg and issue the corresponding command if needed ...
  1042. defc scredrec_inf
  1043.    parse arg sender msg_type msg_value
  1044. ;;   sayerror 'sender is' sender ', msg_type is ' msg_type ', and msg_value is ' msg_value ' ...'
  1045.    --- temporary fix
  1046.    msg_value = leftstr(msg_value, 1)
  1047.  
  1048.    if msg_type = SCREDREC_StartRecording_msg then
  1049. ;;      sayerror 'SCREDREC_StartRecording_msg ...'
  1050.       call finish_push_record_button(msg_value)
  1051.       return
  1052.    endif
  1053.    if msg_type = SCREDREC_StopRecording_msg then
  1054. ;;      sayerror 'SCREDREC_StopRecording_msg ...'
  1055.       call finish_stop_recording(msg_value)
  1056.       return
  1057.    endif
  1058.    if msg_type = SCREDREC_Play_msg then
  1059. ;;      sayerror 'SCREDREC_Play_msg ...'
  1060.       call finish_push_play_button(msg_value)
  1061.       return
  1062.    endif
  1063.    if msg_type = SCREDREC_Compile_msg then
  1064. ;;      sayerror 'SCREDREC_Compile_msg ...'
  1065.       call finish_compile(msg_value)
  1066.       return
  1067.    endif
  1068.   return
  1069.  
  1070. ;; a command to add source lines, meanwhile without style info ...
  1071. defc scredrec_add
  1072.    parse arg text_addr len .
  1073.    if text_addr = 0 or text_addr = '' then
  1074.      return
  1075.    endif
  1076.    if len <= 0 or len = '' then
  1077.      return
  1078.    endif
  1079.  
  1080.    bufaddr = atol(text_addr)
  1081.  
  1082.    text = oldpeek32(bufaddr,len)
  1083.  
  1084.    first = 1
  1085.    LF = substr(atoi(10),1,1)    -- \n ...
  1086.    CR = substr(atoi(13),1,1)    -- \r ...
  1087.    eol = CR||LF
  1088.    while len > 0 do
  1089.      linend = verify(text, eol, 'match', first)
  1090.      if linend = 0 then        -- end of line not found ...
  1091.         line = substr(text,first,len)
  1092.         len = 0
  1093.      else
  1094.         line = substr(text,first,linend-first)
  1095.         len = len - (linend-first) -1        -- counting eol
  1096.         next = linend + 1
  1097.         lastchar = substr(text,linend,1)
  1098.         nextchar = substr(text,next,1)
  1099.         if lastchar <> nextchar and pos(nextchar,eol) > 0 then          -- catching CR||LF or LF||CR
  1100.             next = next +1
  1101.             len = len -1
  1102.         endif
  1103.      endif
  1104.      insertline line, .last + 1
  1105.      first = next
  1106.    endwhile
  1107.  
  1108.     --- now, free the text buffer and return ...
  1109.    retc = dynalink32('scredrec','free_buf', bufaddr, 2)
  1110.  
  1111.    return
  1112.  
  1113. ;;; the following is only for debugging ...
  1114. defc set_recording
  1115.    universal OSA_play, OSA_record, OSA_synt_check
  1116.  
  1117.    parse arg s
  1118.    if s = '' then       -- unset
  1119.       OSA_record = OSA_off
  1120.    else
  1121.       OSA_record = OSA_on
  1122.    endif
  1123.  
  1124.    call set_OSA_status()
  1125.  
  1126.    return
  1127.  
  1128. defc set_play
  1129.    universal OSA_play, OSA_record, OSA_synt_check
  1130.  
  1131.    parse arg s
  1132.    if s = '' then       -- unset
  1133.       OSA_play = OSA_off
  1134.    else
  1135.       OSA_play = OSA_on
  1136.    endif
  1137.  
  1138.    call set_OSA_status()
  1139.  
  1140.    return
  1141.  
  1142. defc print_scredrec_global_vars
  1143.    universal source_version, compiled_source_version, temp_source_version
  1144.    universal tmp_fn, source_only
  1145.    universal scredrec_modified
  1146.    universal scredrec_last_modified
  1147.  
  1148.    sayerror 'source_version =' source_version
  1149.    sayerror 'compiled_source_version =' compiled_source_version
  1150.    sayerror 'temp_source_version =' temp_source_version
  1151.    sayerror 'tmp_fn =' tmp_fn
  1152.    sayerror 'source_only =' source_only
  1153.    sayerror 'scredrec_modified =' scredrec_modified
  1154.    sayerror 'scredrec_last_modified =' scredrec_last_modified
  1155.  
  1156. ;; get command should add EDIT option 'scred_get' to avoid updating source&compiled IDs ...
  1157. defc get=
  1158.    universal default_edit_options
  1159. ;;'echo on'
  1160.    get_file = strip(arg(1))
  1161.    if get_file='' then sayerror NO_FILENAME__MSG 'GET'; stop endif
  1162.    if pos(argsep,get_file) then
  1163.       sayerror INVALID_OPTION__MSG
  1164.       stop
  1165.    endif
  1166.    call parse_filename(get_file,.filename)
  1167.    getfileid fileid
  1168.    s_last=.last
  1169.    display -1
  1170.    'e /scred_get /q /d' get_file
  1171.    editrc=rc
  1172.    .visible = 0
  1173.    getfileid gfileid
  1174.    refresh
  1175.    if editrc = -282 | not .last | gfileid = fileid then   -- -282 = sayerror('New file')
  1176.       display 1
  1177.       if editrc = -282 | gfileid = fileid then
  1178.          sayerror FILE_NOT_FOUND__MSG':  'get_file
  1179.       else
  1180.          sayerror FILE_IS_EMPTY__MSG':  'get_file
  1181.       endif
  1182.       activatefile fileid
  1183.       refresh
  1184. ;;      'postme keep_one_file_in_the_ring'
  1185.       stop
  1186.    endif
  1187.    if editrc & editrc<>-278 then  -- -278  sayerror('Lines truncated') then
  1188.       display 1
  1189.       sayerror editrc
  1190.       activatefile fileid
  1191.       refresh
  1192. ;;      'postme keep_one_file_in_the_ring'
  1193.       stop
  1194.    endif
  1195.    call psave_mark(save_mark)
  1196. compile if WANT_BOOKMARKS
  1197.    if not .levelofattributesupport then
  1198.       'loadattributes'
  1199.    endif
  1200. compile endif
  1201.    get_file_attrib = .levelofattributesupport
  1202.    top
  1203.    mark_line
  1204.    bottom
  1205.    mark_line
  1206.    activatefile fileid
  1207.    rc=0
  1208.    copy_mark
  1209.    copy_rc=rc           -- Test for memory too full for copy_mark.
  1210.    activatefile gfileid
  1211.    'xcom q'
  1212.    parse value save_mark with s_firstline s_lastline s_firstcol s_lastcol s_mkfileid s_mt
  1213.    if fileid=s_mkfileid then           -- May have to move the mark.
  1214.       diff=fileid.last-s_last          -- (Adjustment for difference in size)
  1215.       if fileid.line<s_firstline then s_firstline=s_firstline+diff; endif
  1216.       if fileid.line<s_lastline then s_lastline=s_lastline+diff; endif
  1217.    endif
  1218.    call prestore_mark(s_firstline s_lastline s_firstcol s_lastcol s_mkfileid s_mt)
  1219.    activatefile fileid
  1220.    if get_file_attrib // 2 then
  1221.       call attribute_on(1)  -- Colors flag
  1222.    endif
  1223.    if get_file_attrib bitand 4 then
  1224.       call attribute_on(4)  -- Mixed fonts flag
  1225.    endif
  1226.    if get_file_attrib bitand 8 then
  1227.       call attribute_on(8)  -- "Save attributes" flag
  1228.    endif
  1229.    display 1
  1230.    if copy_rc then
  1231.       sayerror NOT_2_COPIES__MSG get_file
  1232.    endif
  1233. ;;sayerror "get almost finished ..."
  1234.    'postme keep_one_file_in_the_ring'
  1235. ;;   'sayfileid'
  1236.    stop
  1237.  
  1238. ;; defc test_NLS_str
  1239. ;;   name = scred_NLS_string('OSA_bar__msg')
  1240. ;;   sayerror 'the OSA bar msg is ' name ' ...'
  1241. ;;   name = scred_NLS_string('Unknown_msg')
  1242. ;;   sayerror 'the Unknown msg is ' name ' ...'
  1243.  
  1244. ;; get a string from a DLL; uses the function 'get_NLS_string_len' defined in SCREDREC.DLL
  1245. defproc scred_NLS_string(strname)
  1246.    s = NULL
  1247.    lib='scrednls'||\0
  1248. ;;   sayerror 'strname = ' strname ' ...'
  1249.    strname=strname||\0
  1250.    strlen = dynalink32('scredrec','get_NLS_string_len', address(lib)||
  1251.                                                                 address(strname)||
  1252.                                                                 address(s), 2)
  1253.    if s == NULL then
  1254.       strvalue = ' ... '        -- undefined ...
  1255. ;;      sayerror 'scred_NLS_string: strvalue undefined ...'
  1256.    elseif strlen = 0 then
  1257.       strvalue = ''
  1258. ;;      sayerror 'scred_NLS_string: strvalue empty str ...'
  1259.    else
  1260.       strvalue = oldpeek32(ltoa(s,10),strlen)
  1261. ;;      sayerror 'scred_NLS_string: strvalue' strvalue '...'
  1262.    endif
  1263.    return strvalue
  1264.