home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / epmsmp.zip / WEBSORT.E < prev    next >
Text File  |  1996-02-06  |  3KB  |  118 lines

  1. /*     ---  For IBM WebExplorer users  ---
  2. The following will load the copy of your EXPLORE.INI from your ETC
  3. directory and sort the contents of the Quicklist.  If you start the
  4. Web Explorer with the /i option to handle multiple EXPLORE.INI files,
  5. you can explicitly pass the fully-qualified name of your .INI file as
  6. an argument.
  7.  
  8. This can be compiled (ETPM WEBSORT) and used as an external command,
  9. or can be included in your base EPM configuration.  It would be best
  10. run using EPM 6; the shorter line length of EPM 5.51 will probably be
  11. too limiting.  (In any case, this should be "safe" - it won't trash your
  12. EXPLORE.INI if the data is too long to be handled.)
  13.  
  14. Larry Margolis, margoli@watson.IBM.com
  15. */
  16.  
  17. compile if not defined(ERROR__MSG)
  18.    include 'english.e'
  19.  compile if not defined(MAXCOL)
  20.    MAXCOL = 255
  21.  compile endif
  22.  
  23.    defmain
  24.       'websort' arg(1)
  25. compile endif
  26.  
  27. defc websort =
  28.    if arg(1)<>'' then
  29.       inifilename = arg(1)
  30.    else
  31.       inifilename = get_env('ETC')'\explore.ini'
  32.    endif
  33.    getfileid startfid
  34.    'e /d' inifilename
  35.    if rc then
  36.       if rc=-282 then  -- sayerror("New file")
  37.          'quit'
  38.          sayerror inifilename 'does not exist.'
  39.       else
  40.          sayerror 'Error' rc 'loading' inifilename '-' sayerrortext(rc)
  41.       endif
  42.       return
  43.    endif
  44.    'xcom l /[quicklist]/'
  45.    if rc then
  46.       sayerror 'Quicklist heading not found.'
  47.       return
  48.    endif
  49.    getfileid inifid
  50.    startline = .line + 1
  51.    'xcom e /c .temp'
  52.    if rc<>sayerror('New file') then
  53.       sayerror ERROR__MSG rc BAD_TMP_FILE__MSG sayerrortext(rc)
  54.       return rc
  55.    endif
  56.    getfileid tempfid
  57.    .autosave = 0
  58.    do i = startline to inifid.last by 2
  59.       if i>inifid.last then
  60.          leave
  61.       endif
  62.       getline line, i, inifid
  63.       if leftstr(line, 11)<>'quicklist= ' then
  64.          leave
  65.       endif
  66.       if i+1>inifid.last then
  67.          sayerror 'Bad EXPLORE.INI file - missing URL for "'substr(line, 12)'"'
  68.          return
  69.       endif
  70.       getline line2, i+1, inifid
  71.       insertline line || \1 || line2, .last+1
  72.       if length(line) + length(line2)>=MAXCOL then
  73.          bottom
  74.          .modify = 0
  75. compile if MAXCOL = 255
  76.          sayerror 'Text + URL too long to handle - use EPM 6.x instead.'
  77. compile else
  78.          sayerror 'Text + URL too long to handle, sorry.'
  79. compile endif
  80.          return
  81.       endif
  82.    enddo
  83.    if not .modify then
  84.       'quit'
  85.       sayerror 'Empty quicklist.'
  86.       return
  87.    endif
  88.    result = sort(2, .last, 12, 55, tempfid, 'I' )
  89.    if result then
  90.       sayerror 'SORT' ERROR_NUMBER__MSG result
  91.       stop
  92.    endif
  93.    old_autosave = inifid.autosave
  94.    inifid.autosave = 0
  95.    old_modify = inifid.modify
  96.    do i = 2 to .last
  97.       getline line, i
  98.       parse value textline(i) with line1 \1 line2
  99.       replaceline line1, startline, inifid
  100.       replaceline line2, startline+1, inifid
  101.       startline = startline + 2
  102.    enddo
  103.    .modify = 0
  104.    'quit'
  105.    activatefile inifid   -- Insurance...
  106.    .modify = old_modify + 1
  107.    .autosave = old_autosave
  108.    'file'
  109.    if not rc then
  110.       sayerror 'All done!'
  111.       activatefile startfid
  112.    endif
  113. /*
  114. [quicklist]
  115. quicklist= Watson Research home page
  116. http://mp.watson.ibm.com/xw-wat
  117. */
  118.