home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / kmmepm04.zip / kenMMepm.e < prev   
Text File  |  1996-04-08  |  10KB  |  263 lines

  1.  
  2.       /****************************************************/
  3.       /*                                                  */
  4.       /*                                                  */
  5.       /*       "kenMMepm" adds the ability to quickly     */
  6.       /*    select the name of a multi-media file (or     */
  7.       /*    Internet URL) embedded in a text file and     */
  8.       /*    automatically launch the appropriate          */
  9.       /*    application for viewing/listening             */
  10.       /*    to/accessing that file.                       */
  11.       /*                                                  */
  12.       /*     See the kenMMepm.doc for instructions.       */
  13.       /*                                                  */
  14.       /*       copyright Ken Arway 1996                   */
  15.       /*                                                  */
  16.       /*                                                  */
  17.       /****************************************************/
  18.  
  19.  
  20. ; This line is a comment because it has a semi-colon in column one
  21.  
  22.  
  23. include 'STDCONST.E'
  24.  
  25. const
  26.    FTP_APP = 'FTPPM.EXE'  -- change to match your preferences in the Internet section
  27.    local_dir = '0'  -- change for your setup (if using FTPPM.EXE)
  28.    KMM_MENU_MSG='~MMedia' -- remove when MYCNF.E has 'em for access by MOUSE.E 
  29.    KMM_MENUP_MSG=\1'View/Hear/GoTo selected file or location'  -- ditto
  30.  
  31. definit  -- not used when items added to popup menu
  32.    universal defaultmenu, activemenu
  33.    deletemenu defaultmenu, 6, 0, 0
  34.    buildsubmenu defaultmenu, 65, KMM_MENU_MSG, 'get_dataname'KMM_MENUP_MSG, 0, 0
  35.    call readd_help_menu()
  36.    call maybe_show_menu()
  37.  
  38.  
  39. defc view_data
  40.    universal dataname
  41.    universal DataExt
  42.    universal DataDir
  43.    universal current_dir
  44.  
  45.    KMM_DATA_MSG='Data name is '
  46.    current_dir = directory()  -- save the current directory
  47.    if pos('.', .filename)<>1 & DataDir='' then
  48.       CurrFile = .filename 
  49.       place = lastpos('\', CurrFile)-1
  50.       DataDir = leftstr(CurrFile, place)
  51.       'cd' DataDir
  52.    elseif leftstr(.filename, 8)='.DOS dir'|leftstr(.filename, 14)='.command_shell' then
  53.       'cd' DataDir
  54.    elseif leftstr(.filename, 5)='.tree'|leftstr(.filename, 4)='.DIR' then
  55.       if pos('\', dataname) then
  56.          place = lastpos('\', dataname)-1
  57.          DataDir = leftstr(dataname, place)
  58.          'cd' DataDir
  59.       endif
  60.    else 'cd' DataDir
  61.    endif
  62.    sayerror KMM_DATA_MSG || dataname''
  63.  
  64. ;  -- User changes go below here --
  65.  
  66. ;  This is the Internet section:
  67.  
  68.    if upcase(leftstr(dataname, 7))='HTTP://' then
  69.       'start /F linkup.exe explore.exe -t 8 -q "'||dataname'"'
  70.    elseif upcase(leftstr(dataname, 6))='FTP://' then
  71.    compile if FTP_APP = 'FTPPM.EXE'
  72. ;  These next 10 lines are only used if FTPPM.EXE is being used for FTP access
  73.       dataname=substr(dataname, 7)  -- this line strips out the URL type
  74.          slash = pos('/', dataname)
  75.          if  slash <> '0' then
  76.             host = leftstr(dataname, (slash-1))
  77.             rem_dir = substr(dataname, slash)
  78.          else
  79.             host = dataname
  80.             rem_dir = '0'
  81.          endif
  82.          'start /F linkup.exe ftppm.exe '||host' anonymous name@address 0 0 "'||local_dir' "'||rem_dir'" * * 2'
  83. ;  The above 10 lines are used only for FTPPM.EXE
  84.    compile else
  85. ;  These next 2 lines are only used if an alternate app is being used for FTP access
  86. ;         dataname=substr(dataname, 7)  -- this line strips out the URL type (remove if using WebEx for FTP)
  87.          'start /F linkup.exe explore.exe -t 8 -q "'||dataname'"'
  88. ;  The above 2 lines are only used for alternate FTP apps
  89.    compile endif
  90.    elseif upcase(leftstr(dataname, 9))='GOPHER://' then
  91.       dataname=substr(dataname, 10)  -- this line strips out the URL type
  92.       slash = pos('/', dataname)
  93.       host = leftstr(dataname, (slash-1))
  94.       sub_dir = substr(dataname, (slash))
  95.       dataname = host||' 1'||sub_dir
  96.       'start /F linkup.exe gopher.exe "'||dataname'"'
  97.    elseif upcase(leftstr(dataname, 9))='TELNET://' then
  98.       dataname=substr(dataname, 10)  -- this line strips out the URL type
  99.       'start /F linkup.exe telnetpm.exe "'||dataname'"'
  100.    elseif upcase(leftstr(dataname, 5))='NEWS:' then
  101.       'start /F linkup.exe explore.exe -t 8 -q "'||dataname'"'
  102.    elseif upcase(leftstr(dataname, 7))='MAILTO:' then
  103.       'start /F linkup.exe explore.exe -t 8 -q "'||dataname'"'
  104.    elseif pos('@', dataname) then  -- these 3 lines must stay
  105.       dataname = 'mailto:' || dataname  -- at the end of
  106.       'start /F linkup.exe explore.exe -t 8 -q "'||dataname'"'  -- the Internet section
  107.  
  108.  
  109. ;   This is the section for other apps:
  110.  
  111.    elseif pos(DataExt, 'GIF JPG BMP TIF') then
  112.       'start /F d:\grafx\showgif.exe "'||dataname'"'
  113.    elseif DataExt='ZIP' then
  114.       'start /F d:\fmanip\zipme\zipme.exe "'||dataname'"'
  115.    elseif DataExt='ICO' then
  116.       'start /F iconedit.exe "'||dataname'"'
  117. ;   elseif DataExt='PDF' then
  118. ;      'start /F d:\os2apps\acrobat\acroread.exe "'||dataname'"'
  119. ;   elseif DataExt='DS4' then
  120. ;      'start /WIN d:\winapps\ds41\ds40.ese "'||dataname'"'
  121.    elseif pos(DataExt, 'HTM HTML') then
  122.       'start /F explore.exe -t 8 -q "'||dataname'"'
  123.    elseif DataExt='MPG' then
  124.       'start /F d:\grafx\pmmpeg\pmmpeg.exe "'||dataname'"'
  125.    elseif DataExt='AVI' then
  126.       'start /F vb.exe "'||dataname'"'
  127.    elseif pos(DataExt, 'WAV MID') then
  128.       'start /F ab.exe "'||dataname'"'
  129.    elseif DataExt='INF' then
  130.       'start /F view.exe "'||dataname'"'
  131.    elseif DataExt='HLP' then
  132.       'start /F viewhelp.exe "'||dataname'"'
  133.    elseif  pos(DataExt, 'DOC TXT') then
  134.       'start /F e.exe "'||dataname'"'
  135.  
  136.  
  137. ;  -- No user changes are needed below this line --
  138.  
  139.    else
  140.       KMM_DATA_MSG='Unrecognized data format: '
  141.    endif
  142.    call directory(current_dir)  -- restore the previous current directory
  143.       sayerror KMM_DATA_MSG || dataname''
  144.       DataExt=''  -- reset DataExt to null
  145.       DataDir=''  -- reset DataDir to null
  146.  
  147.  
  148. defc get_dataname
  149.    universal dataname
  150.    universal DataExt
  151.    universal DataDir
  152.    universal default_search_options
  153.    universal current_dir
  154.  
  155.    getsearch search_command -- save user's search command
  156.    center_search = 0
  157.    call psave_pos(save_pos) -- save cursor's initial position
  158.  
  159.    if leftstr(.filename, 8)='.DOS dir'|leftstr(.filename, 14)='.command_shell' then
  160.       finddirstart = 'Directory of '
  161.       case = 'e'
  162.       direction = '-R'
  163.       'L '\1 || finddirstart\1'x'case||direction
  164.       getline Dirline
  165.       DataDir = substr(Dirline, 14)
  166.       call prestore_pos(save_pos)  -- restore cursor's initial position
  167.       refresh  -- removes locate circle
  168.    endif  -- ".DOS dir" directory find
  169.  
  170.    if marktype() then
  171.       mkt = leftstr(marktype(),1)
  172.          if mkt <>'C' then
  173.             sayerror 'Text must be marked with a Character mark'
  174.          else
  175.             getmark first_line, last_line, first_col, last_col, mark_fileid
  176.             getline nameline, first_line
  177.             dataname = substr(nameline,first_col,((last_col+1)-first_col))
  178.                if pos('.', dataname)<>0 then 
  179.                   dot = lastpos('.', dataname)+1
  180.                   DataExt = upcase(substr(dataname, dot))
  181.                      if DataDir='' & pos('\', dataname) then
  182.                         place = lastpos('\', dataname)-1
  183.                         DataDir = leftstr(dataname, place)
  184.                      endif
  185.                endif
  186.          endif -- mkt
  187.       if leftstr(.filename, 8)='.DOS dir'|leftstr(.filename, 14)='.command_shell' then
  188.          dataname = DataDir||'\'||dataname
  189.       endif
  190.    sayerror 'Data name is '||dataname''
  191.       if leftstr(.filename, 8)='.DOS dir'|leftstr(.filename, 14)='.command_shell' then
  192.          call prestore_pos(save_pos)  -- restore cursor's initial position
  193.          setsearch search_command  -- restore user's search command
  194.          default_search_options    -- reset user's search options
  195.          if .line <> .last then  -- resets the cursor's original line (sometimes)
  196.             .line = .line+1
  197.          else .last
  198.          endif
  199.       endif
  200.    'view_data'
  201.  
  202.    else 
  203.       getline nameline
  204.       len = length(nameline)
  205.  
  206.       finddatastart = '~:n[^\\\.\:\$\&\@\~\#%/_-]|^.'
  207.       case = 'c'
  208.       direction = '-R'
  209.       'L '\1 || finddatastart\1'x'case||direction
  210.       if .col=1 then
  211.          if pos('~:n[^\$\&\@\~\#%/_-]', nameline, .col, 'X')=1 then
  212.             datastart = .col+1
  213.          else
  214.             datastart = 1
  215.          endif
  216.       else datastart = .col+1
  217.       endif
  218.  
  219.       direction = '+F'
  220.       finddataend = '~:n[^\\\.\:\$\~\@\#\&%/_-]|.$'
  221.       call prestore_pos(save_pos) -- recall cursor's initial position
  222.       'L '\1 || finddataend\1'x'case||direction
  223.       if .col=len then
  224.          if pos('~:n[^\$\&\@\~\#%/_-]', nameline, (.col-1), 'X') then
  225.             dataend = .col-1
  226.          else 
  227.             dataend = .col
  228.          endif
  229.       else dataend = .col-1
  230.       endif
  231.       call prestore_pos(save_pos) -- recall cursor's initial position
  232.       if .line <> .last then  -- resets the cursor's original line (sometimes)
  233.          .line = .line+1
  234.       else .last
  235.       endif
  236.       refresh   -- gets rid of the locate circle
  237.  
  238.       dataname = substr(nameline, datastart, ((dataend-datastart)+1))
  239.          if pos('.', dataname)<>0 then 
  240.             dot = lastpos('.', dataname)+1
  241.             DataExt = upcase(substr(dataname, dot))
  242.                if DataDir='' & pos('\', dataname) then
  243.                   place = lastpos('\', dataname)-1
  244.                   DataDir = leftstr(dataname, place)
  245.                endif
  246.          endif
  247.       setsearch search_command  -- retrieve user's search command
  248.       default_search_options    -- reset user's search options
  249.       if leftstr(.filename, 8)='.DOS dir'|leftstr(.filename, 14)='.command_shell' then
  250.          dataname = DataDir||'\'||dataname
  251.       endif
  252.       sayerror 'Data name is '||dataname''
  253.       'view_data'
  254.    endif -- get_dataname
  255.  
  256.  
  257. defexit   -- not used when item is added to popup menu
  258.    universal defaultmenu, activemenu
  259.    deletemenu defaultmenu,65,0,0
  260.    call maybe_show_menu()
  261.  
  262.  
  263.