home *** CD-ROM | disk | FTP | other *** search
/ Aminet 10 / aminetcdnumber101996.iso / Aminet / biz / dopus / Dopus511.lha / LhADirOpus5V10.lha / LhADir / arexx / LhADir.dopus5 < prev   
Text File  |  1995-05-27  |  19KB  |  697 lines

  1. /*
  2.   $VER: LhADir.dopus5 1.0 (25.5.95)
  3.   Copyright © 1995 by Edmund Vermeulen.
  4.   Placed in the public domain. No restrictions on distribution or usage.
  5.  
  6.   ARexx script for Directory Opus 5 to show the contents of an LhA archive
  7.   in an Opus lister and operate on the files and directories inside the
  8.   archive as if it is a normal directory.
  9. */
  10.  
  11. ver='$VER: LhADir.dopus5 1.0C (25.5.95)'  /* for compiled version */
  12.  
  13. signal on syntax        /* intercept syntax errors */
  14. options results         /* need results */
  15. options failat 21       /* external commands are allowed return code 20 */
  16. numeric digits 10       /* needed for convertdate routine */
  17. lf='0a'x                /* ascii code for linefeed */
  18.  
  19. if ~show('l','rexxsupport.library') then
  20.    call addlib('rexxsupport.library',0,-30)  /* needed for delay() */
  21.  
  22. /* init locale */
  23. ok=show(l,'locale.library')
  24. if ~ok then
  25.    ok=addlib('locale.library',0,-30)
  26. if ok then
  27.    catalog=opencatalog('LhADir.catalog','english',0)
  28.  
  29. parse arg cmd portname . '"' dblclck '"' handle .
  30. upper cmd
  31. if portname~='' then
  32.    address value portname
  33. else
  34.    portname=address()
  35. parse var portname '.' portno  /* port number */
  36.  
  37. if handle='' then do
  38.    lister query source
  39.    if rc>0 then
  40.       call quitit
  41.    parse var result handle .  /* only need first source */
  42.    end
  43.  
  44. lister query handle numselentries
  45. entries=result
  46.  
  47. if dblclck~=='' then do
  48.    entries=1
  49.    if right(dblclck,1)='/' then do
  50.       filetype=1
  51.       selentry=left(dblclck,length(dblclck)-1)
  52.       end
  53.    else do
  54.       filetype=-1
  55.       selentry=dblclck
  56.       end
  57.    end
  58. else
  59.    if entries>0 then
  60.       call getfirstone
  61.  
  62. call checklhadir(handle)
  63.  
  64. topline=''
  65. listlha=0
  66. notmove=cmd~='MOVE'
  67.  
  68. select
  69.    when cmd='GETDIR' then
  70.       call dogetdir
  71.    when cmd='BROWSE' then
  72.       call dogetdir
  73.    when cmd='GETSIZES' then
  74.       call dogetsizes
  75.    when cmd='DELETE' then
  76.       call dodelete
  77.    when cmd='COPY' then
  78.       call docopy
  79.    when cmd='MOVE' then
  80.       call docopy
  81.    when cmd='MAKEDIR' then
  82.       call domakedir
  83.    otherwise
  84.       if lhadir then do
  85.          lister select handle '"'selentry'"' off
  86.          lister refresh handle
  87.          address command 'LhA e -q -x2 -Qo "'patch(lhafile,0)'" T: "'patch(lhasubdir||selentry,1)'"'
  88.          if rc>0 then
  89.             call quitit(getcatstr(11,'Error while extracting from archive.'))
  90.          thisfile='"T:'selentry'"'
  91.          command cmd thisfile
  92.          lister wait handle
  93.          do until rc~=20  /* keep trying until not in use */
  94.             call delay(200)
  95.             address command 'Delete >NIL:' thisfile 'QUIET'
  96.             end
  97.          end
  98.       else
  99.          command cmd
  100.    end
  101.  
  102. call quitit(topline)  /* finished */
  103.  
  104.  
  105. dogetdir:
  106.  
  107.    if ~show('p','LhADir-handler'portno) then
  108.       address command 'Run >NIL: <NIL: rx DOpus5:arexx/LhADir-handler' portname
  109.    oldlhadir=lhadir
  110.    if entries>0 then
  111.       if filetype>0 then  /* list a new dir */
  112.          if lhadir then
  113.             lhasubdir=lhasubdir||selentry'/'
  114.          else
  115.             winpath=winpath||selentry'/'
  116.       else do  /* list an archive file */
  117.          if pos('|'upper(right(selentry,4)'|'),'|.LHA|.LZH|.RUN|')=0 then
  118.             call quitit(getcatstr(18,'Sorry, LhADir.dopus5 can only'lf'list LhA archives.'))
  119.          if lhadir then do
  120.             lister query dest
  121.             if rc>0 then
  122.                call quitit(getcatstr(9,'No destination selected!'))
  123.             parse var result desthandle .
  124.             lister query desthandle path
  125.             destpath=result
  126.             dopus request '"'getcatstr(20,'This is an archive in an archive.'lf||lf'Extract it to'lf"'%s'"lf'and then list it?',destpath)'"' getcatstr(21,'Extract|Cancel')
  127.             if ~rc then
  128.                call quitit
  129.             address command 'LhA e -q -x2 -a -C0 -Qo "'patch(lhafile,0)'" "'destpath'" "'patch(lhasubdir||selentry,1)'"'
  130.             if rc>0 then
  131.                call quitit(getcatstr(11,'Error while extracting from archive.'))
  132.             lister read desthandle '"'destpath'"' force
  133.             lhafile=destpath||selentry
  134.             end
  135.          else
  136.             lhafile=winpath||selentry
  137.  
  138.          lhadir=1
  139.          lhasubdir=''
  140.          listlha=1
  141.          end
  142.  
  143.    lister select handle '"'selentry'"' off
  144.    lister refresh handle
  145.  
  146.    if lhadir then do
  147.       if cmd='BROWSE' then do
  148.          oldhandle=handle
  149.          lister new
  150.          handle=result
  151.          lister set handle title getcatstr(0,'LhADir listed archive')
  152.          lister set handle source
  153.          address command 'Copy >NIL: T:LhADir.list'oldhandle 'T:LhADir.list'handle
  154.          end
  155.       else do
  156.          if ~oldlhadir then
  157.             lister empty handle  /* use a new cache */
  158.          lister set handle title getcatstr(0,'LhADir listed archive')
  159.          end
  160.       call showlhadir
  161.       end
  162.    else
  163.       if cmd='BROWSE' then
  164.          command scandir new winpath
  165.       else do
  166.          if entries=0 then
  167.             winpath=''
  168.          command scandir winpath
  169.          end
  170.    return
  171.  
  172.  
  173. dodelete:
  174.  
  175.    askdelete=1
  176.    if lhadir then do
  177.       if entries=0 then
  178.          call quitit
  179.       if notmove then do
  180.          lister set handle busy on
  181.          if askdelete then do
  182.             lister query handle numselfiles
  183.             nfiles=result
  184.             lister query handle numseldirs
  185.             ndirs=result
  186.             dopus request '"'getcatstr(5,'Warning: you cannot get back'lf'what you delete! OK to delete:'lf||lf'%s file(s) and'lf'%s drawer(s) (and their contents)?',nfiles,ndirs)'"' getcatstr(6,'Proceed|Cancel')
  187.             if ~rc then
  188.                call quitit
  189.             end
  190.          call getall
  191.          end
  192.       call open('actionfile','T:actionfile'handle,'w')
  193.       do i=1 to entries
  194.          if type.i>0 then
  195.             wild='/#?'
  196.          else
  197.             wild=''
  198.          call writeln('actionfile','"'patch(lhasubdir||name.i,1)||wild'"')
  199.          lister remove handle '"'name.i'"'
  200.          end
  201.       call close('actionfile')
  202.       lister set handle progress '-1' getcatstr(7,'Deleting from archive...')
  203.       address command 'LhA d -q -Qp -Qo "'patch(lhafile,0)'" @T:actionfile'handle
  204.       if rc>0 then do
  205.          topline=getcatstr(8,'Error while deleting from archive.')
  206.          listlha=1
  207.          call showlhadir
  208.          end
  209.       else
  210.          lister refresh handle
  211.       address command 'Delete >NIL: T:actionfile'handle 'QUIET'
  212.       address command 'Delete >NIL: T:LhADir.list'handle 'QUIET'  /* archive has changed */
  213.       lister set handle busy off
  214.       end
  215.    else do
  216.       command delete
  217.       lister wait handle
  218.       end
  219.    return
  220.  
  221.  
  222. docopy:
  223.  
  224.    if entries=0 then
  225.       call quitit
  226.    problem=0
  227.    src=winpath
  228.    s_lhadir=lhadir
  229.    s_lhafile=lhafile
  230.    s_lhasubdir=lhasubdir
  231.    lister query dest
  232.    if rc>0&lhadir then
  233.       call quitit(getcatstr(9,'No destination selected!'))
  234.    parse var result desthandle .  /* only need first destination */
  235.    call checklhadir(desthandle)
  236.  
  237.    if s_lhadir then do
  238.       lister set handle busy on
  239.       lister set desthandle busy on
  240.       if lhadir then
  241.          winpath='T:LhADir'handle'/'lhasubdir
  242.       call getall
  243.       call lhaextract
  244.       if lhadir then do
  245.          src=winpath
  246.          call lhaadd
  247.          end
  248.       else
  249.          if problem then do
  250.             lister set desthandle busy off
  251.             lister read desthandle '"'destpath'"' force
  252.             end
  253.          else do
  254.             do i=1 to entries
  255.                lister query handle entry '"'name.i'"' stem fileinfo.
  256.                if fileinfo.type>0 then
  257.                   fileinfo.size=0
  258.                lister add desthandle '"'name.i'"' fileinfo.size fileinfo.type fileinfo.date fileinfo.protstring fileinfo.comment
  259.                end
  260.             lister refresh desthandle
  261.             end
  262.       end
  263.    else
  264.       if lhadir then do
  265.          lister set handle busy on
  266.          if ~notmove then do
  267.             cuthere=lastpos('/',lhafile)
  268.             if cuthere=0 then
  269.                cuthere=pos(':',lhafile)
  270.             name=substr(lhafile,cuthere+1)
  271.             if left(lhafile,length(src))==src then do
  272.                name=substr(lhafile,length(src)+1)
  273.                parse var name name '/'
  274.                lister query handle entry '"'name'"' stem fileinfo.
  275.                if fileinfo.selected then
  276.                   call quitit(getcatstr(19,'You can''t move an archive into itself!'))
  277.                end
  278.             end
  279.          lister set desthandle busy on
  280.          call getall
  281.          call lhaadd
  282.          end
  283.       else do /* normal copy or move */
  284.          if notmove then
  285.             command copy
  286.          else
  287.             command move
  288.          lister wait handle
  289.          end
  290.  
  291.    lister set handle busy off
  292.    lister set desthandle busy off
  293.    if (s_lhadir|lhadir)&~notmove&~problem then do
  294.       lhadir=s_lhadir
  295.       lhafile=s_lhafile
  296.       lhasubdir=s_lhasubdir
  297.       lister query handle abort
  298.       if result then
  299.          call quitit(getcatstr(3,'Aborted...'))
  300.       lister set handle busy off
  301.       lister wait handle
  302.       call dodelete
  303.       end
  304.    return
  305.  
  306.  
  307. dogetsizes:
  308.  
  309.    if lhadir then do
  310.       lister set handle busy on
  311.       lister set handle progress '-1' getcatstr(14,'Scanning directories...')
  312.       lister query handle numseldirs
  313.       ndirs=result
  314.       lister query handle seldirs stem dname.
  315.       n=1
  316.       do i=0 to dname.count-1
  317.          dirname.n=dname.i
  318.          lister query handle entry '"'dirname.n'"' stem fileinfo.
  319.          if fileinfo.size=0 then
  320.             n=n+1
  321.          end
  322.       dirsize.=0
  323.       dirsecs.=0
  324.       ndirs=n-1
  325.       call readlist(0)
  326.       lister set handle busy off
  327.       end
  328.    else
  329.       command getsizes
  330.    return
  331.  
  332.  
  333. domakedir:
  334.  
  335.    lister set handle busy on
  336.    dopus getstring '"'getcatstr(15,'Enter directory name or archive name.lha')'" 31 ""' getcatstr(16,'OK|Cancel')
  337.    dirtomake=result
  338.    if dirtomake==''|dirtomake='RESULT' then
  339.       call quitit
  340.    now=date('i')*86400+time('s')
  341.    if lhadir then do  /* create empty dir in archive */
  342.       call createdirs(dirtomake'/')
  343.       address command 'LhA a -q -e -r -Qo "'patch(lhafile,0)'" T:LhADir'handle'/' '"'patch(lhasubdir||dirtomake,1)'"'
  344.       if rc>0 then
  345.          topline=getcatstr(13,'Error while adding to archive.')
  346.       else do
  347.          lister add handle '"'dirtomake'" -1 1' now '----rwed'
  348.          lister refresh handle
  349.          end
  350.       address command 'Delete >NIL: T:LhADir'handle 'ALL QUIET'
  351.       address command 'Delete >NIL: T:LhADir.list'handle 'QUIET'
  352.       end
  353.    else
  354.       if upper(right(dirtomake,4))=='.LHA' then  /* create new archive */
  355.          if open('emptyarchive',winpath||dirtomake,'w') then do
  356.             call writech('emptyarchive','0'x)
  357.             call close('emptyarchive')
  358.             command protect 'NAME "'winpath||dirtomake'" CLEAR e'
  359.             lister add handle '"'dirtomake'" 1 -1' now '----rw-d'
  360.             lister refresh handle
  361.             end
  362.          else
  363.             topline=getcatstr(17,'Error creating archive.')
  364.       else do /* normal makedir */
  365.          lister set handle busy off
  366.          command makedir 'NOICON NAME "'dirtomake'"'
  367.          end
  368.     return
  369.  
  370.  
  371. showlhadir:
  372.  
  373.    lister clear handle
  374.    lister set handle busy on
  375.    lister set handle progress '-1' getcatstr(1,'Listing archive...')
  376.    lister set handle handler 'LhADir-handler'portno
  377.    lister set handle path lhafile'/'lhasubdir
  378.    lister refresh handle full
  379.    now=date('i')*86400+time('s')
  380.    ndirs=0
  381.    call readlist(1)
  382.    return
  383.  
  384.  
  385. readlist:
  386.  
  387.    arg show  /* showdir or getsizes? */
  388.    if ~exists(lhafile) then
  389.       call quitit(getcatstr(22,'Error, archive not found.'))
  390.    if listlha|~exists('T:LhADir.list'handle) then
  391.       call lhalist
  392.    call open('tempfile','T:LhADir.list'handle,'r')
  393.    do 3
  394.       call readln('tempfile')  /* waste the first 3 lines */
  395.       end
  396.  
  397.    compstr=upper(lhasubdir)
  398.    complen=length(compstr)
  399.    nextline=readln('tempfile')
  400.  
  401.    do forever
  402.       name=nextline
  403.       infoline=readln('tempfile')
  404.       do while pos('% ',infoline)<22
  405.          name=infoline
  406.          infoline=readln('tempfile')
  407.          end
  408.       if name=='-------- ------- ----- --------- --------' then
  409.          leave
  410.       nextline=readln('tempfile')
  411.       if left(nextline,1)==':' then do
  412.          parse var nextline 3 comment
  413.          nextline=readln('tempfile')
  414.          end
  415.       else
  416.          comment=''
  417.  
  418.       if upper(left(name,complen))==compstr then do
  419.          name=substr(name,complen+1)
  420.          if name~==''&pos('"',name)=0 then do
  421.             if pos('/',name)>0 then do  /* it's a dir */
  422.                parse var name dirname '/'
  423.                olddir=0
  424.                i=ndirs+1
  425.                do while i>1&~olddir
  426.                   i=i-1
  427.                   olddir=upper(dirname)==upper(dirname.i)
  428.                   end
  429.                if olddir&~show then do
  430.                   call convertdate
  431.                   dirsize.i=dirsize.i+size
  432.                   if seconds>dirsecs.i then
  433.                      dirsecs.i=seconds
  434.                   end
  435.                if show&~olddir then do  /* a new dir */
  436.                   ndirs=ndirs+1
  437.                   dirname.ndirs=dirname
  438.                   lister add handle '"'dirname'" -1 1' now '----rwed'
  439.                   end
  440.                end
  441.             else  /* it's a file */
  442.                if show then do
  443.                   call convertdate
  444.                   lister add handle '"'name'"' size '-1' seconds atts comment
  445.                   end
  446.             end
  447.          end
  448.       end
  449.    call close('tempfile')
  450.    if ~show then
  451.       do i=1 to ndirs
  452.          lister add handle '"'dirname.i'"' dirsize.i '1' dirsecs.i '----rwed'
  453.          lister select handle '"'dirname.i'"' on
  454.          end
  455.    lister refresh handle full
  456.    return
  457.  
  458.  
  459. checklhadir:
  460.  
  461.    arg checkhandle
  462.    lister query checkhandle path
  463.    winpath=result
  464.    test=upper(winpath)
  465.    cuthere=pos('.LHA/',test)
  466.    if cuthere=0 then
  467.       cuthere=pos('.LZH/',test)
  468.    if cuthere=0 then
  469.       cuthere=pos('.RUN/',test)
  470.    lhadir=cuthere>0
  471.    if lhadir then do
  472.       lhafile=left(winpath,cuthere+3)
  473.       lhasubdir=substr(winpath,cuthere+5)
  474.       end
  475.    return
  476.  
  477.  
  478. lhaextract:
  479.  
  480.    lister query handle numdirs
  481.    anydirs=result>0
  482.    mustmove=anydirs&s_lhasubdir~==''
  483.    if mustmove then
  484.       destpath=winpath'LhADir'handle'/'
  485.    else
  486.       destpath=winpath
  487.  
  488.    call open('actionfile','T:actionfile'handle,'w')
  489.    do i=1 to entries
  490.       if type.i>0 then
  491.          wild='/#?'
  492.       else
  493.          wild=''
  494.       call writeln('actionfile','"'patch(s_lhasubdir||name.i,1)||wild'"')
  495.       end
  496.    call close('actionfile')
  497.  
  498.    if anydirs then
  499.       lhacmd='x'
  500.    else
  501.       lhacmd='e -x2'
  502.    lister set handle progress '-1' getcatstr(10,'Extracting from archive...')
  503.    address command 'LhA' lhacmd '-q -a -C0 -Qo "'patch(s_lhafile,0)'" "'destpath'" @T:actionfile'handle
  504.    problem=rc>0
  505.    if problem then
  506.       topline=getcatstr(11,'Error while extracting from archive.')
  507.    else
  508.       if notmove then do
  509.          do i=1 to entries
  510.             lister select handle '"'name.i'"' off
  511.             end
  512.          lister refresh handle
  513.          end
  514.  
  515.    if mustmove then do
  516.       address command 'Rename >NIL: "'winpath'LhADir'handle'/'s_lhasubdir'#?" "'winpath'" QUIET'
  517.       address command 'Delete >NIL: "'winpath'LhADir'handle'" ALL QUIET'
  518.       end
  519.    address command 'Delete >NIL: T:actionfile'handle 'QUIET'
  520.    return
  521.  
  522.  
  523. lhaadd:
  524.  
  525.    mustcopy=upper(right(src,length(lhasubdir)))~==upper(lhasubdir)
  526.    if mustcopy then do  /* all files must be copied to T: before they can be added */
  527.       homedir='T:LhADir'handle'/'
  528.       call createdirs
  529.       end
  530.    else
  531.       homedir=left(src,length(src)-length(lhasubdir))
  532.    call open('actionfile','T:actionfile'handle,'w')
  533.    call writeln('actionfile','"'patch(homedir,0)'"')
  534.  
  535.    if s_lhadir then
  536.       call writeln('actionfile','#?')
  537.    else do
  538.       do i=1 to entries
  539.          call writeln('actionfile','"'patch(lhasubdir||name.i,0)'"')
  540.          if mustcopy then
  541.             address command 'Copy "'src||name.i'" "T:LhADir'handle'/'lhasubdir'"'
  542.          end
  543.       end
  544.    call close('actionfile')
  545.  
  546.    if pos('.LZH/',test)>0 then
  547.       method='-0'
  548.    else
  549.       method=''
  550.    lister set desthandle progress '-1' getcatstr(12,'Adding to archive...')
  551.    address command 'LhA r' method '-q -e -r -Qo "'patch(lhafile,0)'" @T:actionfile'handle
  552.    problem=rc>0
  553.    if problem then
  554.       topline=getcatstr(13,'Error while adding to archive.')
  555.    else
  556.       if notmove then do
  557.          do i=1 to entries
  558.             lister select handle '"'name.i'"' off
  559.             end
  560.          lister refresh handle
  561.          end
  562.    address command 'Delete >NIL: T:actionfile'handle 'QUIET'
  563.    if mustcopy|s_lhadir then
  564.       address command 'Delete >NIL: T:LhADir'handle 'ALL QUIET'
  565.  
  566.    call swapactive
  567.    listlha=1
  568.    call showlhadir
  569.    call swapactive
  570.    return
  571.  
  572.  
  573. lhalist:
  574.  
  575.    address command 'LhA >T:LhADir.list'handle 'vv -N -Qw -Qo "'lhafile'"'
  576.    if rc>0 then
  577.       call quitit(getcatstr(2,'Error while listing archive.'))
  578.    return
  579.  
  580.  
  581. swapactive:
  582.  
  583.    swaphandle=handle
  584.    handle=desthandle
  585.    desthandle=swaphandle
  586.    return
  587.  
  588.  
  589. createdirs:
  590.  
  591.    parse arg subdir
  592.    dirstocreate='T:LhADir'handle'/'lhasubdir||subdir
  593.    here=0
  594.    mdstring=''
  595.    do until here=0
  596.       here=pos('/',dirstocreate,here+1)
  597.       if here>0 then
  598.          mdstring=mdstring '"'left(dirstocreate,here-1)'"'
  599.       end
  600.    address command 'MakeDir >NIL:' mdstring
  601.    return
  602.  
  603.  
  604. getall:
  605.  
  606.    lister query handle numseldirs
  607.    ndirs=result
  608.    lister query handle seldirs
  609.    do n=1 to ndirs
  610.       parse var result '"' name.n '"' result
  611.       type.n=1
  612.       end
  613.    lister query handle numselfiles
  614.    nfiles=result
  615.    lister query handle selfiles
  616.    do n=ndirs+1 to ndirs+nfiles
  617.       parse var result '"' name.n '"' result
  618.       type.n=-1
  619.       end
  620.    entries=ndirs+nfiles
  621.    return
  622.  
  623.  
  624. convertdate:  /* convert a file's datestamp to seconds past 01-Jan-78 */
  625.  
  626.    parse var infoline size . '% ' day '-' month '-' year ' ' hours ':' minutes ':' seconds atts .
  627.    minus=day='00'
  628.    if minus then
  629.       day='01'
  630.    century=19+(year<78)
  631.    month=pos(month,'  JanFebMarAprMayJunJulAugSepOctNovDec')/3
  632.    month=right(month,2,'0')
  633.    if month='00' then
  634.       month='01'
  635.    seconds=seconds+minutes*60+hours*3600+(date('i',century||year||month||day,'s')-minus)*86400
  636.    return
  637.  
  638.  
  639. getfirstone:
  640.  
  641.    lister query handle firstsel
  642.    selentry=result
  643.    lister query handle entry selentry stem fileinfo.
  644.    selentry=fileinfo.name
  645.    filetype=fileinfo.type
  646.    return
  647.  
  648.  
  649. patch:  /* patch filenames containing strange characters */
  650.  
  651.    parse arg patched,apostrophe
  652.    verstr='*#?|%()[]~'
  653.    if apostrophe then
  654.       verstr=verstr"'"
  655.    pos=1
  656.    do until here=0
  657.       here=verify(substr(patched,pos),verstr,'m')
  658.       if here>0 then do
  659.          pos=pos+here+1
  660.          patched=insert("'",patched,pos-3)
  661.          end
  662.       end
  663.    if left(patched,1)='@' then
  664.       patched='*'patched
  665.    return patched
  666.  
  667.  
  668. getcatstr:
  669.  
  670.    parse arg msgno,msgstring,insert.1,insert.2
  671.    if catalog~=0 then
  672.       msgstring=getcatalogstr(catalog,msgno,msgstring)
  673.    i=0
  674.    do while pos('%s',msgstring)>0
  675.       parse var msgstring fore '%s' aft
  676.       i=i+1
  677.       msgstring=fore||insert.i||aft
  678.       end
  679.    return msgstring
  680.  
  681.  
  682. syntax:
  683.  
  684.    call quitit('Syntax Error' rc',' errortext(rc) 'in line' sigl'.')
  685.  
  686.  
  687. quitit:
  688.  
  689.    parse arg topline
  690.    lister clear handle progress
  691.    lister set handle busy off
  692.    if catalog~=0 then
  693.       call closecatalog(catalog)
  694.    if topline~=='' then
  695.       dopus request '"'topline'"' getcatstr(4,'OK')
  696.    exit
  697.