home *** CD-ROM | disk | FTP | other *** search
/ The Developer Connection…ice Driver Kit for OS/2 3 / DEV3-D1.ISO / editors / epm / sampmacs / main.e < prev    next >
Encoding:
Text File  |  1993-12-14  |  4.1 KB  |  142 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 activemenu, 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.  
  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
  101.    showmenu activemenu   /* show the default EPM menu           */
  102.   compile if SUPPORT_USERS_GUIDE
  103.    'postme cascade_menu 620'
  104.   compile endif
  105.   compile if SUPPORT_TECHREF
  106.    'postme cascade_menu 630'
  107.   compile endif
  108.   compile if WANT_TOOLBAR
  109.    'postme cascade_menu 430 431'
  110.   compile endif
  111.   compile if DEBUG_MAIN
  112.    messageNwait('DEFMAIN: after SHOWMENU')
  113.   compile endif
  114.  compile endif
  115.    if should_showwindow then
  116.       call showwindow('ON')
  117.  compile if DEBUG_MAIN
  118.    messageNwait('DEFMAIN: after SHOWWINDOW')
  119.  compile endif
  120.    endif
  121. compile endif
  122.  
  123. compile if WANT_PROFILE
  124.  compile if WANT_PROFILE='SWITCH'
  125.    if REXX_PROFILE then
  126.  compile endif
  127.       profile = 'profile.erx'
  128.       findfile profile1, profile, EPATH
  129.       if rc then findfile profile1, profile, 'PATH'; endif
  130.       if not rc then
  131. compile if 0 -- debug for LaMail
  132.          if isadefproc('write_debug_file') then
  133.             write_debug_file(getpminfo(EPMINFO_EDITCLIENT)':  calling rexx profile' profile1 'w/ arg "'arg(1)'"'\13\10, 0)
  134.          endif
  135. compile endif
  136.          'rx' profile1 arg(1)
  137.       endif
  138.  compile if WANT_PROFILE='SWITCH'
  139.    endif
  140.  compile endif
  141. compile endif
  142.