home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / epmmac.zip / MAIN.E < prev    next >
Text File  |  1994-10-12  |  6KB  |  180 lines

  1. define DEBUG_MAIN = 0
  2.  
  3. defmain    /* defmain should be used to parse the command line arguments */
  4. compile if WANT_PROFILE='SWITCH'
  5.    universal REXX_PROFILE
  6. compile endif
  7. compile if EVERSION < 5
  8.    universal comsfileid, messy
  9. compile else
  10.    universal should_showwindow
  11.    should_showwindow = 1  -- Lets cmdline commands inhibit the SHOWWINDOW.
  12. compile endif
  13.  
  14.    doscmdline = 'e 'arg(1) /* Can do special processing of DOS command line.*/
  15. ; sayerror 'DosCmdLine = "'arg(1)'"'
  16.    unnamed_name=UNNAMED_FILE_NAME  -- Define the name once to save a few bytes.
  17.    .filename = unnamed_name      -- Ver. 3.11:  Don't rely on fileid.
  18.  
  19. compile if DEBUG_MAIN
  20.    messageNwait('DEFMAIN: arg(1)="'arg(1)'"')
  21. compile endif
  22.  
  23. compile if EVERSION < 5
  24.    if messy then .windowoverlap=1; endif    -- messy-desk style?
  25. compile endif
  26.  
  27. compile if EPM
  28.  compile if WANT_APPLICATION_INI_FILE
  29.    'initconfig'                  -- Check if anything of interest is in OS2.INI
  30.   compile if DEBUG_MAIN
  31.    messageNwait('DEFMAIN: after INITCONFIG')
  32.   compile endif
  33.  compile endif
  34. compile endif
  35.  
  36. compile if (EPM and (HOST_SUPPORT='EMUL' | HOST_SUPPORT='E3EMUL') and not defined(my_SAVEPATH)) or DELAY_SAVEPATH_CHECK
  37.    call check_savepath()
  38. compile endif
  39.  
  40. compile if SUPPORT_USER_EXITS
  41.    if isadefproc('defmain_exit') then
  42.       call defmain_exit(doscmdline)
  43.    endif
  44. compile endif
  45.  
  46.    doscmdline                    -- Execute the doscmdline.
  47.  
  48. compile if DEBUG_MAIN
  49.    messageNwait('DEFMAIN: after DOSCMDLINE')
  50. compile endif
  51.  
  52.    getfileid newfileid
  53. compile if EVERSION < 5
  54.    if 'e'<>doscmdline then  /* Put doscmdline into coms stack if nontrivial.*/
  55.       getline line,comsfileid.last,comsfileid
  56.       if line<>doscmdline then  -- Don't duplicate last line
  57.          if comsfileid.last > 30 then deleteline 1,comsfileid endif  -- trim if too big
  58.          insertline doscmdline,comsfileid.last+1,comsfileid
  59.       endif
  60.    endif
  61. compile endif
  62.  
  63.    /* E automatically created an empty file when it started.              */
  64.    /* If user specified file(s) to edit, get rid of the empty file.       */
  65. do i=1 to 1
  66.    getfileid emptyfileid, UNNAMED_FILE_NAME
  67.    if emptyfileid='' then             -- User deleted it?
  68.       leave
  69.    endif
  70.    if emptyfileid.modify then         -- User changed it?
  71.       leave
  72.    endif
  73.    if newfileid=emptyfileid then      -- Check if others in ring.
  74. compile if EVERSION < 5
  75.       if messy then nextwindow else nextfile endif
  76.       getfileid newfileid
  77.       if messy then prevwindow else prevfile endif
  78. compile else
  79.       nextfile
  80.       getfileid newfileid
  81.       prevfile
  82. compile endif
  83.    endif
  84.    if newfileid<>emptyfileid then
  85.       activatefile emptyfileid
  86.       'xcom q'
  87. compile if EPM and MENU_LIMIT
  88.       call updateringmenu()
  89. compile endif
  90.       activatefile newfileid
  91.       call select_edit_keys()
  92.    endif
  93. end
  94.  
  95. compile if CURSOR_ON_COMMAND and not EPM
  96.    cursor_command
  97. compile endif
  98.  
  99. compile if EPM
  100.  compile if INCLUDE_MENU_SUPPORT & not DELAY_MENU_CREATION
  101.    call showmenu_activemenu()  -- show the EPM menu (before the window is shown)
  102.   compile if DEBUG_MAIN
  103.    messageNwait('DEFMAIN: after SHOWMENU')
  104.   compile endif
  105.  compile endif
  106.    if should_showwindow then
  107.  compile if DELAY_MENU_CREATION
  108.   compile if defined(STD_MENU_NAME)
  109.    compile if STD_MENU_NAME = 'OVSHMENU.E'  -- This is one we know about...
  110.       showmenu 1002, 5
  111.    compile endif
  112.    compile if STD_MENU_NAME = 'FEVSHMNU.E'  -- This is the only other one we know about...
  113.       showmenu 1003, 5
  114.    compile endif
  115.   compile else  -- STD_MENU_NAME not defined; we're using STDMENU.E:
  116.       showmenu 1001, 5
  117.   compile endif
  118.  compile endif -- DELAY_MENU_CREATION
  119.       call showwindow('ON')
  120.  compile if DEBUG_MAIN
  121.    messageNwait('DEFMAIN: after SHOWWINDOW')
  122.  compile endif
  123.    endif
  124. compile endif
  125.  
  126. compile if EPM
  127.  compile if DELAY_MENU_CREATION
  128.   compile if 1  -- Ready for when ability to load from RC is in...
  129.    'postme main2'
  130.   compile else
  131.    'main2' arg(1)
  132.   compile endif
  133.  
  134. defc main2  -- Everything after the SHOWWINDOW is a separate command, posted so as not to slow down initial display of window.
  135.    universal appname, app_hini
  136.  compile if WANT_STACK_CMDS = 'SWITCH'
  137.    universal stack_cmds
  138.  compile endif
  139.  compile if WPS_SUPPORT
  140.    universal wpshell_handle
  141.  compile endif
  142.  compile if WANT_CUA_MARKING = 'SWITCH'
  143.    universal CUA_marking_switch
  144.  compile endif
  145.  compile if CHECK_FOR_LEXAM
  146.    universal LEXAM_is_available
  147.  compile endif
  148.  compile if WANT_PROFILE='SWITCH'
  149.    universal REXX_PROFILE
  150.  compile endif
  151.    include 'menuacel.e'
  152.  compile if INCLUDE_MENU_SUPPORT
  153.    call showmenu_activemenu()  -- show the EPM menu (after the window is shown)
  154.   compile if DEBUG_MAIN
  155.    messageNwait('DEFMAIN: after SHOWMENU')
  156.   compile endif
  157.  compile endif
  158. compile endif -- DELAY_MENU_CREATION
  159. compile endif -- EPM
  160.  
  161. compile if WANT_PROFILE
  162.  compile if WANT_PROFILE='SWITCH'
  163.    if REXX_PROFILE then
  164.  compile endif
  165.       profile = 'profile.erx'
  166.       findfile profile1, profile, EPATH
  167.       if rc then findfile profile1, profile, 'PATH'; endif
  168.       if not rc then
  169. compile if 0 -- debug for LaMail
  170.          if isadefproc('write_debug_file') then
  171.             write_debug_file(getpminfo(EPMINFO_EDITCLIENT)':  calling rexx profile' profile1 'w/ arg "'arg(1)'"'\13\10, 0)
  172.          endif
  173. compile endif
  174.          'rx' profile1 arg(1)
  175.       endif
  176.  compile if WANT_PROFILE='SWITCH'
  177.    endif
  178.  compile endif
  179. compile endif
  180.