home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 4 / AACD04.ISO / AACD / Online / Upd8 / Upd8 next >
Text File  |  1999-11-17  |  53KB  |  1,666 lines

  1. /*******************************************
  2. $VER: Upd8 1.2 by Carl Licke / Turbid design
  3. http://home.swipnet.se/turbid/
  4. *******************************************/
  5.  
  6.  
  7.  
  8. /*** scheme ***/
  9.  
  10.  
  11.  
  12. SIGNAL ON halt
  13. SIGNAL ON break_c
  14. SIGNAL ON failure
  15. SIGNAL ON ioerr
  16. SIGNAL ON syntax
  17.  
  18. CALL init
  19. CALL readprefsfile
  20. CALL readlistfile
  21. CALL main
  22. CALL writelistfile
  23. CALL TR_DELETEAPP(app)
  24.  
  25. EXIT 0
  26.  
  27.  
  28.  
  29. /*** various ***/
  30.  
  31.  
  32.  
  33. init:
  34.    version  ='1.2'
  35.  
  36.    lf       =X2C('0A')
  37.    cr       =X2C('0D')
  38.    crlf     =X2C('0D0A')
  39.    tab      =X2C('09')
  40.    asterisk =X2C('2A')
  41.    null     =X2C('00000000')
  42.    oldlist.0=0
  43.    newlist.0=0
  44.    modified =0
  45.    failsopen=0
  46.  
  47.    PARSE SOURCE . . . src .
  48.    progdir=LEFT(src,MAX(LASTPOS(':',src),LASTPOS('/',src)))
  49.  
  50.    IF ~SHOW('L','tritonrexx.library') THEN IF ~ADDLIB('tritonrexx.library',10,-30,0) THEN DO
  51.       SAY 'tritonrexx.library required.'
  52.       CALL errorexit
  53.    END
  54.  
  55.    taglist='TRCA_Name "Upd8"',
  56.       'TRCA_LongName  "Upd8"',
  57.       'TRCA_Info      "Detects updated webpages."',
  58.       'TRCA_Version   "'version'"',
  59.       'TRCA_Date      "18.12.1998"',
  60.    'TAG_END'
  61.  
  62.    app=TR_CREATEAPP(taglist)
  63.    IF app=null THEN CALL report(1,'Could not create application.')
  64.  
  65.    IF ~SHOW('L','rexxsupport.library') THEN IF ~ADDLIB('rexxsupport.library',0,-30,0) THEN CALL report(1,'rexxsupport.library required.')
  66.    IF ~SHOW('L','rxsocket.library')    THEN IF ~ADDLIB('rxsocket.library',0,-30,0)    THEN CALL report(1,'rxsocket.library required.')
  67.  
  68.    IF EXISTS('libs:rmh.library') & EXISTS('libs:openurl.library') THEN DO
  69.       ourllib=1
  70.       CALL REMLIB('rmh.library')
  71.       CALL REMLIB('openurl.library')
  72.       CALL ADDLIB('rmh.library',5,-30,0)
  73.       CALL ADDLIB('openurl.library',0,-66,3)
  74.    END
  75.    ELSE ourllib=0
  76.  
  77.    taglist.main=WindowID(1),
  78.       PubScreenName('Workbench'),
  79.       WindowTitle('Upd8' version),
  80.       'VertGroupA',
  81.          'HorizGroupA',
  82.             'VertGroupA',
  83.                'SpaceS',
  84.                NamedSeparator('locations'),
  85.                'SpaceS',
  86.                ListSSN('oldlist',101,0,0) 'TRAT_MinHeight 6',
  87.                'HorizGroupEA',
  88.                   'HorizGroupA',
  89.                      Button('_verify',111),
  90.                      Button('_new',105),
  91.                      Button('_delete',106),
  92.                   'EndGroup',
  93.                   'HorizGroupA',
  94.                      Button('_edit',109),
  95.                      Button('_browse',107),
  96.                      Button('_show',114),
  97.                   'EndGroup',
  98.                'EndGroup',
  99.                'HorizGroupEA',
  100.                   'HorizGroupA',
  101.                      Button('verify mar_ked',113),
  102.                      ButtonR('verify al_l',104),
  103.                   'EndGroup',
  104.                'EndGroup',
  105.                'SpaceS',
  106.                NamedSeparator('updated locations'),
  107.                'SpaceS',
  108.                ListSSC('newlist',102,0,0) 'TRAT_MinHeight 2',
  109.                'HorizGroupEA',
  110.                   'HorizGroupA',
  111.                      Button('f_orget',126),
  112.                   'EndGroup',
  113.                   'HorizGroupA',
  114.                      Button('d_ata',129),
  115.                      Button('b_rowse',127),
  116.                      Button('s_how',134),
  117.                   'EndGroup',
  118.                'EndGroup',
  119.             'EndGroup',
  120.          'EndGroup',
  121.          'SpaceS',
  122.          'HorizGroupA',
  123.             'SpaceS',
  124.             ClippedTextID('No locations verified.',110) 'TRAT_Flags TRTX_NOUNDERSCORE',
  125.             'SpaceS',
  126.          'EndGroup',
  127.          'SpaceS',
  128.          Progress(100,0,103),
  129.          'HorizGroupA',
  130.             Button('_import BookCon',115),
  131.             Button('_prefs',112),
  132.             ButtonE('_quit',108),
  133.          'EndGroup',
  134.       'EndGroup',
  135.    'EndProject'
  136.  
  137.    taglist.new=WindowID(5),
  138.       PubScreenName('Workbench'),
  139.       WindowPosition('TRWP_CENTERDISPLAY'),
  140.       WindowFlags('TRWF_ACTIVATESTRGAD'),
  141.       WindowTitle('Upd8 - new location'),
  142.       'VertGroupA',
  143.          'SpaceS',
  144.          'LineArray',
  145.             'BeginLine',
  146.                'SpaceS' TextNR('_name') 'TRAT_ID 511 SpaceS',
  147.                StringGadget('',511) 'TRAT_Value 512 TRAT_Flags TRST_NORETURNBROADCAST SpaceS',
  148.             'EndLine',
  149.             'SpaceS',
  150.             'BeginLine',
  151.                'SpaceS' TextNR('_URL') 'TRAT_ID 512 SpaceS',
  152.                StringGadget('',512) 'TRAT_Value 512 TRAT_Flags TRST_NORETURNBROADCAST SpaceS',
  153.             'EndLine',
  154.             'SpaceS',
  155.             'BeginLine',
  156.                'SpaceS' TextNR('_separate viewing URL') 'TRAT_ID 514 SpaceS',
  157.                StringGadget('',514) 'TRAT_Value 512 TRAT_Flags TRST_NORETURNBROADCAST SpaceS',
  158.             'EndLine',
  159.             'SpaceS',
  160.             'BeginLine',
  161.                'SpaceS' TextNR('_force size method') 'TRAT_ID 513 SpaceS',
  162.                'HorizGroupSA' CheckBox(513) 'TRAT_Value 0 EndGroup SpaceS',
  163.             'EndLine',
  164.          'EndArray',
  165.          'SpaceS',
  166.          'HorizGroupA',
  167.             ButtonR('a_dd',502),
  168.             ButtonE('_abort',503),
  169.          'EndGroup',
  170.       'EndGroup',
  171.    'EndProject'
  172. RETURN 0
  173.  
  174.  
  175.  
  176. main:
  177.    window.main=TR_OPENPROJECT(app,taglist.main)
  178.    CALL redrawlists
  179.    IF startcheck THEN CALL check
  180.    stoploop.main=0
  181.  
  182.    DO UNTIL stoploop.main
  183.       CALL TR_WAIT(app,'')
  184.       DO WHILE TR_HANDLEMSG(app,'event')
  185.          SELECT
  186.             WHEN event.trm_class='TRMS_ACTION' THEN SELECT
  187.                WHEN event.trm_id=104 THEN CALL check
  188.                WHEN event.trm_id=113 THEN CALL check('MARKED')
  189.                WHEN event.trm_id=115 THEN CALL importbookcon
  190.                WHEN event.trm_id=105 THEN CALL new
  191.                WHEN event.trm_id=106 THEN CALL delete
  192.                WHEN event.trm_id=108 THEN stoploop.main=1
  193.                WHEN event.trm_id=111 THEN CALL check(TR_GETATTRIBUTE(window.main,101,'TRAT_Value')+1)
  194.                WHEN event.trm_id=112 THEN CALL prefs
  195.                WHEN event.trm_id=126 THEN CALL forget
  196.  
  197.                WHEN event.trm_id=109 THEN DO; CALL getinfo(1); CALL edit;     END
  198.                WHEN event.trm_id=107 THEN DO; CALL getinfo(1); CALL browse;   END
  199.                WHEN event.trm_id=114 THEN DO; CALL getinfo(1); CALL showhtml; END
  200.  
  201.                WHEN event.trm_id=129 THEN DO; CALL getinfo(2); CALL data;     END
  202.                WHEN event.trm_id=127 THEN DO; CALL getinfo(2); CALL browse;   END
  203.                WHEN event.trm_id=134 THEN DO; CALL getinfo(2); CALL showhtml; END
  204.  
  205.                WHEN event.trm_id=902 THEN DO
  206.                   CALL TR_CLOSEPROJECT(window.failslist)
  207.                   failsopen=0
  208.                END
  209.                OTHERWISE NOP
  210.             END
  211.             WHEN event.trm_class='TRMS_NEWVALUE' THEN SELECT
  212.                WHEN BITAND(D2X(event.trm_qualifier),X2C('0200'))~=X2C('0200') THEN NOP
  213.                WHEN event.trm_id=101 THEN CALL mark
  214.                WHEN event.trm_id=102 THEN DO; CALL getinfo(2); CALL data; END
  215.                OTHERWISE NOP
  216.             END
  217.             WHEN event.trm_class='TRMS_KEYPRESSED' THEN SELECT
  218.                WHEN event.trm_code=64 THEN DO
  219.                   CALL mark
  220.                   IF number<oldlist.0 THEN CALL TR_SETATTRIBUTE(window.main,101,'TRAT_Value',number)
  221.                END
  222.                OTHERWISE NOP
  223.             END
  224.             WHEN event.trm_class='TRMS_CLOSEWINDOW' THEN DO
  225.                IF event.trm_project=window.main THEN stoploop.main=1
  226.                ELSE IF event.trm_project=window.failslist THEN DO
  227.                   CALL TR_CLOSEPROJECT(window.failslist)
  228.                   failsopen=0
  229.                END
  230.             END
  231.             OTHERWISE NOP
  232.          END
  233.       END
  234.    END
  235. RETURN 0
  236.  
  237.  
  238.  
  239. mark:
  240.    number=TR_GETATTRIBUTE(window.main,101,'TRAT_Value')+1
  241.    IF SUBSTR(oldlist.number,1,1)==' ' THEN oldlist.number=OVERLAY('>',oldlist.number)
  242.    ELSE oldlist.number=OVERLAY(' ',oldlist.number)
  243.    CALL TR_SETATTRIBUTE(window.main,101,'TROB_Listview','oldlist')
  244. RETURN 0
  245.  
  246.  
  247.  
  248. redrawlists:
  249.    IF oldlist.0>0 THEN DO
  250.       CALL TR_SETATTRIBUTE(window.main,104,'TRAT_Disabled',0)
  251.       CALL TR_SETATTRIBUTE(window.main,106,'TRAT_Disabled',0)
  252.       CALL TR_SETATTRIBUTE(window.main,111,'TRAT_Disabled',0)
  253.       CALL TR_SETATTRIBUTE(window.main,109,'TRAT_Disabled',0)
  254.       CALL TR_SETATTRIBUTE(window.main,107,'TRAT_Disabled',0)
  255.       CALL TR_SETATTRIBUTE(window.main,113,'TRAT_Disabled',0)
  256.       CALL TR_SETATTRIBUTE(window.main,114,'TRAT_Disabled',0)
  257.    END
  258.    ELSE DO
  259.       CALL TR_SETATTRIBUTE(window.main,104,'TRAT_Disabled',1)
  260.       CALL TR_SETATTRIBUTE(window.main,106,'TRAT_Disabled',1)
  261.       CALL TR_SETATTRIBUTE(window.main,111,'TRAT_Disabled',1)
  262.       CALL TR_SETATTRIBUTE(window.main,109,'TRAT_Disabled',1)
  263.       CALL TR_SETATTRIBUTE(window.main,107,'TRAT_Disabled',1)
  264.       CALL TR_SETATTRIBUTE(window.main,113,'TRAT_Disabled',1)
  265.       CALL TR_SETATTRIBUTE(window.main,114,'TRAT_Disabled',1)
  266.    END
  267.  
  268.    IF newlist.0>0 THEN DO
  269.       CALL TR_SETATTRIBUTE(window.main,126,'TRAT_Disabled',0)
  270.       CALL TR_SETATTRIBUTE(window.main,129,'TRAT_Disabled',0)
  271.       CALL TR_SETATTRIBUTE(window.main,127,'TRAT_Disabled',0)
  272.       CALL TR_SETATTRIBUTE(window.main,134,'TRAT_Disabled',0)
  273.    END
  274.    ELSE DO
  275.       CALL TR_SETATTRIBUTE(window.main,126,'TRAT_Disabled',1)
  276.       CALL TR_SETATTRIBUTE(window.main,129,'TRAT_Disabled',1)
  277.       CALL TR_SETATTRIBUTE(window.main,127,'TRAT_Disabled',1)
  278.       CALL TR_SETATTRIBUTE(window.main,134,'TRAT_Disabled',1)
  279.    END
  280.  
  281.    CALL TR_SETATTRIBUTE(window.main,101,'TROB_Listview','oldlist')
  282.    CALL TR_SETATTRIBUTE(window.main,102,'TROB_Listview','newlist')
  283. RETURN 0
  284.  
  285.  
  286.  
  287. prefs:
  288.    CALL TR_LOCKPROJECT(window.main)
  289.  
  290.    taglist=WindowID(2),
  291.       PubScreenName('Workbench'),
  292.       WindowPosition('TRWP_CENTERDISPLAY'),
  293.       WindowTitle('Upd8 - preferences'),
  294.       'VertGroupA',
  295.          'SpaceS',
  296.          'LineArray',
  297.             'BeginLine',
  298.                'SpaceS' TextNR('_verify all at start') 'TRAT_ID 211 SpaceS',
  299.                'HorizGroupSA' CheckBox(211) 'TRAT_Value' startcheck 'EndGroup',
  300.             'EndLine',
  301.             'SpaceS',
  302.             'BeginLine',
  303.                'SpaceS' TextNR('_continue on error') 'TRAT_ID 219 SpaceS',
  304.                'HorizGroupSA' CheckBox(219) 'TRAT_Value' errorcontinue 'EndGroup',
  305.             'EndLine',
  306.             'SpaceS',
  307.             'BeginLine',
  308.                'SpaceS' TextNR('_notify when ready') 'TRAT_ID 221 SpaceS',
  309.                'HorizGroupSA' CheckBox(221) 'TRAT_Value' notifyready 'EndGroup',
  310.             'EndLine',
  311.             'SpaceS',
  312.             'BeginLine',
  313.                'SpaceS' TextNR('_mark imported') 'TRAT_ID 220 SpaceS',
  314.                'HorizGroupSA' CheckBox(220) 'TRAT_Value' markimported 'EndGroup',
  315.             'EndLine',
  316.             'SpaceS',
  317.             'BeginLine',
  318.                'SpaceS' TextNR('_browser path') 'TRAT_ID 214 SpaceS',
  319.                'HorizGroupA',
  320.                   StringGadget(browser,212) 'TRAT_Value 512 TRAT_Flags TRST_NORETURNBROADCAST',
  321.                   GetFileButton(214) 'SpaceS',
  322.                'EndGroup',
  323.             'EndLine',
  324.             'SpaceS',
  325.             'BeginLine',
  326.                'SpaceS' TextNR('viewer text_width') 'TRAT_ID 213 SpaceS',
  327.                'HorizGroupA',
  328.                   SliderGadget(1,256,textwidth,213) 'SpaceS',
  329.                   Integer(textwidth) 'TRAT_ID 201 TRAT_MinWidth 3',
  330.                   'SpaceS' TextNR('columns') 'SpaceS',
  331.                'EndGroup',
  332.             'EndLine',
  333.             'SpaceS',
  334.             'BeginLine',
  335.                'SpaceS' TextNR('transfer _timeout') 'TRAT_ID 215 SpaceS',
  336.                'HorizGroupA',
  337.                   SliderGadget(0,256,timeout,215) 'SpaceS',
  338.                   Integer(timeout) 'TRAT_ID 216 TRAT_MinWidth 3',
  339.                   'SpaceS' TextNR('seconds') 'SpaceS',
  340.                'EndGroup',
  341.             'EndLine',
  342.             'SpaceS',
  343.             'BeginLine',
  344.                'SpaceS' TextNR('size thres_hold') 'TRAT_ID 217 SpaceS',
  345.                'HorizGroupA',
  346.                   SliderGadget(0,256,threshold,217) 'SpaceS',
  347.                   Integer(threshold) 'TRAT_ID 218 TRAT_MinWidth 3',
  348.                   'SpaceS' TextNR('bytes') 'SpaceS',
  349.                'EndGroup',
  350.             'EndLine',
  351.          'EndArray',
  352.          'SpaceS',
  353.          'HorizGroupA',
  354.             ButtonR('_save',204),
  355.             Button('_use',202),
  356.             ButtonE('_abort',203),
  357.          'EndGroup',
  358.       'EndGroup',
  359.    'EndProject'
  360.  
  361.    stoploop.prefs=0
  362.  
  363.    window.prefs=TR_OPENPROJECT(app,taglist)
  364.    DO UNTIL stoploop.prefs
  365.       CALL TR_WAIT(app,'')
  366.       DO WHILE TR_HANDLEMSG(app,'event')
  367.          IF event.trm_class='TRMS_CLOSEWINDOW' THEN stoploop.prefs=1
  368.          IF event.trm_class='TRMS_NEWVALUE' THEN DO
  369.             IF event.trm_id=213 THEN CALL TR_SETATTRIBUTE(window.prefs,201,'TRAT_Value',event.trm_data)
  370.             IF event.trm_id=215 THEN CALL TR_SETATTRIBUTE(window.prefs,216,'TRAT_Value',event.trm_data)
  371.             IF event.trm_id=217 THEN CALL TR_SETATTRIBUTE(window.prefs,218,'TRAT_Value',event.trm_data)
  372.          END
  373.          IF event.trm_class='TRMS_ACTION' THEN DO
  374.             IF event.trm_id=203 THEN stoploop.prefs=1
  375.             IF (event.trm_id=202 | event.trm_id=204) & ~stoploop.prefs THEN DO
  376.                startcheck    =TR_GETATTRIBUTE(window.prefs,211,'TRAT_Value')
  377.                errorcontinue =TR_GETATTRIBUTE(window.prefs,219,'TRAT_Value')
  378.                notifyready   =TR_GETATTRIBUTE(window.prefs,221,'TRAT_Value')
  379.                markimported  =TR_GETATTRIBUTE(window.prefs,220,'TRAT_Value')
  380.                browser       =TR_GETATTRIBUTE(window.prefs,212,'TROB_String')
  381.                textwidth     =TR_GETATTRIBUTE(window.prefs,213,'TRAT_Value')
  382.                timeout       =TR_GETATTRIBUTE(window.prefs,215,'TRAT_Value')
  383.                threshold     =TR_GETATTRIBUTE(window.prefs,217,'TRAT_Value')
  384.                stoploop.prefs=1
  385.                IF event.trm_id=204 THEN CALL writeprefsfile
  386.             END
  387.             IF event.trm_id=214 THEN IF ASL_REQUESTFILE(window.prefs,'browser',LoadFile('Upd8 - select browser executable','_Select',progdir,'')) THEN CALL TR_SETATTRIBUTE(window.prefs,212,'TROB_String',browser.1)
  388.          END
  389.       END
  390.    END
  391.    CALL TR_CLOSEPROJECT(window.prefs)
  392.  
  393.    CALL TR_UNLOCKPROJECT(window.main)
  394. RETURN 0
  395.  
  396.  
  397.  
  398. report:
  399.    IF ARG(1,'E') THEN error=ARG(1)
  400.    ELSE error=1
  401.  
  402.    IF ARG(2,'E') THEN reportmsg=ARG(2)
  403.  
  404.    taglist=WindowID(6),
  405.       PubScreenName('Workbench'),
  406.       WindowPosition('TRWP_CENTERDISPLAY'),
  407.       WindowTitle('Upd8 - message'),
  408.       'VertGroupA',
  409.          'HorizGroupA',
  410.             'SpaceS',
  411.             'VertGroupA',
  412.                'SpaceS',
  413.                TextN(reportmsg) 'TRAT_Flags TRTX_NOUNDERSCORE',
  414.                'SpaceS',
  415.             'EndGroup',
  416.             'SpaceS',
  417.          'EndGroup',
  418.          'HorizGroupA',
  419.             ButtonRE('_close',601),
  420.          'EndGroup',
  421.       'EndGroup',
  422.    'EndProject'
  423.  
  424.    CALL TR_AUTOREQUEST(app,null,taglist)
  425.  
  426.    IF error THEN CALL errorexit
  427. RETURN 0
  428.  
  429.  
  430.  
  431. encodeurl:
  432.    codeurl =STRIP(ARG(1))
  433.    position=1
  434.    DO WHILE POS(' ',codeurl,position)>0
  435.       position=POS(' ',codeurl,position)
  436.       codeurl =INSERT('20',OVERLAY('%',codeurl,position),position)
  437.       position=position+3
  438.    END
  439. RETURN codeurl
  440.  
  441.  
  442.  
  443. halt:
  444. break_c:
  445.    SAY 'line' sigl': interrupted'
  446.    CALL writelistfile
  447.    CALL TR_DELETEAPP(app)
  448. EXIT 5
  449.  
  450.  
  451.  
  452. errorexit:
  453.    CALL TR_DELETEAPP(app)
  454. EXIT 10
  455.  
  456.  
  457.  
  458. failure:
  459. ioerr:
  460. syntax:
  461.    SAY 'line' sigl':' SOURCELINE(sigl)||lf'error' rc':' ERRORTEXT(rc)||lf
  462.    CALL TR_DELETEAPP(app)
  463. EXIT 10
  464.  
  465.  
  466.  
  467. edit:
  468.    CALL TR_LOCKPROJECT(window.main)
  469.    PARSE VAR name marked' ('method') 'name
  470.  
  471.    taglist=WindowID(8),
  472.       PubScreenName('Workbench'),
  473.       WindowPosition('TRWP_CENTERDISPLAY'),
  474.       WindowFlags('TRWF_ACTIVATESTRGAD'),
  475.       WindowTitle('Upd8 - edit location'),
  476.       'VertGroupA',
  477.          'SpaceS',
  478.          'LineArray',
  479.             'BeginLine',
  480.                'SpaceS' TextNR('_name') 'TRAT_ID 811 SpaceS',
  481.                StringGadget(COMPRESS(name,asterisk),811) 'TRAT_Value 512 TRAT_Flags TRST_NORETURNBROADCAST SpaceS',
  482.             'EndLine',
  483.             'SpaceS',
  484.             'BeginLine',
  485.                'SpaceS' TextNR('_URL') 'TRAT_ID 812 SpaceS',
  486.                StringGadget(url,812) 'TRAT_Value 512 TRAT_Flags TRST_NORETURNBROADCAST SpaceS',
  487.             'EndLine',
  488.             'SpaceS',
  489.             'BeginLine',
  490.                'SpaceS' TextNR('_separate viewing URL') 'TRAT_ID 814 SpaceS',
  491.                StringGadget(vurl,814) 'TRAT_Value 512 TRAT_Flags TRST_NORETURNBROADCAST SpaceS',
  492.             'EndLine',
  493.             'SpaceS',
  494.             'BeginLine',
  495.                'SpaceS' TextNR('comparison method:') 'SpaceS',
  496.                ClippedText(method) 'SpaceS',
  497.             'EndLine',
  498.             'BeginLine',
  499.                'SpaceS' TextNR('comparison data:') 'SpaceS',
  500.                ClippedText(data) 'TRAT_Flags TRTX_NOUNDERSCORE SpaceS',
  501.             'EndLine',
  502.             'SpaceS',
  503.             'BeginLine',
  504.                'SpaceS' TextNR('_force size method') 'TRAT_ID 813 SpaceS',
  505.                'HorizGroupSA' CheckBox(813) 'TRAT_Value' (method='fsze') 'EndGroup SpaceS',
  506.             'EndLine',
  507.          'EndArray',
  508.          'SpaceS',
  509.          'HorizGroupA',
  510.             ButtonR('_change',802),
  511.             ButtonE('_abort',803),
  512.          'EndGroup',
  513.       'EndGroup',
  514.    'EndProject'
  515.  
  516.    stoploop.edit=0
  517.    window.edit  =TR_OPENPROJECT(app,taglist)
  518.    DO UNTIL stoploop.edit
  519.       CALL TR_WAIT(app,'')
  520.       DO WHILE TR_HANDLEMSG(app,'event')
  521.          IF event.trm_class='TRMS_CLOSEWINDOW' THEN stoploop.edit=1
  522.          IF event.trm_class='TRMS_ACTION' THEN DO
  523.             stoploop.edit=1
  524.             IF event.trm_id=802 THEN DO
  525.                IF TR_GETATTRIBUTE(window.edit,813,'TRAT_Value') THEN DO
  526.                   IF method~='fsze' THEN DO
  527.                      IF method~='size' THEN data='unverified'
  528.                      method='fsze'
  529.                   END
  530.                END
  531.                ELSE IF method='fsze' THEN DO
  532.                   method='????'
  533.                   data  ='unverified'
  534.                END
  535.  
  536.                number                   =TR_GETATTRIBUTE(window.main,101,'TRAT_Value')+1
  537.                oldlist.number           =marked' ('method')' TR_GETATTRIBUTE(window.edit,811,'TROB_String')
  538.                oldlist.number.urlstring =encodeurl(TR_GETATTRIBUTE(window.edit,812,'TROB_String'))' 'encodeurl(TR_GETATTRIBUTE(window.edit,814,'TROB_String'))
  539.                oldlist.number.datastring=data
  540.                modified                 =1
  541.                CALL TR_SETATTRIBUTE(window.main,101,'TROB_Listview','oldlist')
  542.             END
  543.          END
  544.       END
  545.    END
  546.    CALL TR_CLOSEPROJECT(window.edit)
  547.  
  548.    CALL TR_UNLOCKPROJECT(window.main)
  549. RETURN 0
  550.  
  551.  
  552.  
  553. data:
  554.    taglist=WindowID(3),
  555.       PubScreenName('Workbench'),
  556.       WindowPosition('TRWP_CENTERDISPLAY'),
  557.       WindowTitle('Upd8 - location data'),
  558.       'VertGroupA',
  559.          'SpaceS',
  560.          'HorizGroupA',
  561.             'SpaceS',
  562.             'LineArray',
  563.                'Beginline',
  564.                   TextNR('name:'),
  565.                   'SpaceS',
  566.                   TextN(COMPRESS(SUBSTR(name,10),asterisk)) 'TRAT_Flags TRTX_NOUNDERSCORE',
  567.                'EndLine',
  568.                'BeginLine',
  569.                   TextNR('URL:'),
  570.                   'SpaceS',
  571.                   TextN(url) 'TRAT_Flags TRTX_NOUNDERSCORE',
  572.                'EndLine',
  573.                'BeginLine',
  574.                   TextNR('separate viewing URL:'),
  575.                   'SpaceS',
  576.                   TextN(vurl) 'TRAT_Flags TRTX_NOUNDERSCORE',
  577.                'EndLine',
  578.                'BeginLine',
  579.                   TextNR('comparison method:'),
  580.                   'SpaceS',
  581.                   TextN(SUBSTR(name,4,4)),
  582.                'EndLine',
  583.                'BeginLine',
  584.                   TextNR('comparison data:'),
  585.                   'SpaceS',
  586.                   TextN(data) 'TRAT_Flags TRTX_NOUNDERSCORE',
  587.                'EndLine',
  588.             'EndArray',
  589.             'SpaceS',
  590.          'EndGroup',
  591.          'SpaceS',
  592.          ButtonRE('_close',301),
  593.       'EndGroup',
  594.    'EndProject'
  595.  
  596.    CALL TR_AUTOREQUEST(app,window.main,taglist)
  597. RETURN 0
  598.  
  599.  
  600.  
  601. browse:
  602.    IF ARG(1,'E') THEN url=ARG(1)
  603.    ELSE IF vurl~='' THEN url=vurl
  604.  
  605.    IF ~ourllib THEN SELECT
  606.       WHEN SHOW('P','IBROWSE.1')       THEN ADDRESS 'IBROWSE.1' 'GOTOURL' '"'url'"'
  607.       WHEN SHOW('P','IBROWSE')         THEN ADDRESS 'IBROWSE' 'GOTOURL' '"'url'"'
  608.       WHEN SHOW('P','AWEB.1')          THEN ADDRESS 'AWEB.1' 'OPEN' '"'url'"'
  609.       WHEN SHOW('P','AWEB.2')          THEN ADDRESS 'AWEB.2' 'OPEN' '"'url'"'
  610.       WHEN SHOW('P','AWebControlPort') THEN ADDRESS 'AWebControlPort' 'OPEN' '"'url'"'
  611.       WHEN SHOW('P','VOYAGER')         THEN ADDRESS 'VOYAGER' 'OPENURL' '"'url'"'
  612.       OTHERWISE DO
  613.          IF browser='' THEN CALL report(0,'No active browser found. Select browser executable.')
  614.          ELSE DO
  615.             IF EXISTS(browser) THEN ADDRESS COMMAND 'run >NIL:' browser '"'url'"'
  616.             ELSE CALL report(0,'The file' browser 'does not exist.')
  617.          END
  618.       END
  619.    END
  620.    ELSE IF OPENURL(url)~=1 THEN CALL report(0,'Failed to open URL.')
  621. RETURN 0
  622.  
  623.  
  624.  
  625. showhtml:
  626.    CALL TR_LOCKPROJECT(window.main)
  627.  
  628.    IF vurl~='' THEN url=vurl
  629.    button2   ='try _browse'
  630.    button3   ='_abort'
  631.    showpage  =1
  632.    listfails =0
  633.    linelist.0=0
  634.  
  635.    taglist=WindowID(4),
  636.       PubScreenName('Workbench'),
  637.       WindowPosition('TRWP_CENTERDISPLAY'),
  638.       WindowTitle('Upd8 - show location'),
  639.       'VertGroupA',
  640.          'HorizGroupA',
  641.             FWListRO('linelist',401,0) 'TRAT_MinWidth' textwidth,
  642.          'EndGroup',
  643.          'SpaceS',
  644.          'HorizGroupA',
  645.             'SpaceS',
  646.             ClippedTextID('Preparing...',402) 'TRAT_Flags TRTX_NOUNDERSCORE',
  647.             'SpaceS',
  648.          'EndGroup',
  649.          'SpaceS',
  650.          'LineArray',
  651.             'BeginLine',
  652.                'SpaceS',
  653.                TextNR('_URL') 'TRAT_ID 403',
  654.                'SpaceS',
  655.                StringGadget('',403) 'TRAT_Value' 512,
  656.             'EndLine',
  657.          'EndArray',
  658.          'HorizGroupA',
  659.             ButtonR('_get',407),
  660.             Button('_abort',404),
  661.             Button('_browse',406),
  662.             ButtonE('_close',405),
  663.          'EndGroup',
  664.       'EndGroup',
  665.    'EndProject'
  666.  
  667.    window.show=TR_OPENPROJECT(app,taglist)
  668.    IF window.show=null THEN CALL report(0,'Could not open show window. Try lower textwidth.')
  669.    ELSE DO
  670.       CALL TR_SETATTRIBUTE(window.show,403,'TROB_String',url)
  671.  
  672.       CALL showhtmlbridge
  673.  
  674.       DO UNTIL stoploop.show
  675.          CALL TR_WAIT(app,'')
  676.          DO WHILE TR_HANDLEMSG(app,'event')
  677.             IF event.trm_class='TRMS_CLOSEWINDOW' THEN stoploop.show=1
  678.             IF event.trm_class='TRMS_ACTION' THEN DO
  679.                IF event.trm_id=407 THEN DO
  680.                   linelist.0=0
  681.                   CALL TR_SETATTRIBUTE(window.show,401,'TROB_Listview','linelist')
  682.                   url =TR_GETATTRIBUTE(window.show,403,'TROB_String')
  683.                   name='  (????) unknown'
  684.                   CALL showhtmlbridge
  685.                END
  686.                IF event.trm_id=405 THEN stoploop.show=1
  687.                IF event.trm_id=406 THEN CALL browse(TR_GETATTRIBUTE(window.show,403,'TROB_String'))
  688.             END
  689.          END
  690.       END
  691.       CALL TR_CLOSEPROJECT(window.show)
  692.    END
  693.    CALL TR_UNLOCKPROJECT(window.main)
  694. RETURN 0
  695.  
  696.  
  697.  
  698. showhtmlbridge:
  699.    infotextadd=''
  700.    pagetitle  ='no title'
  701.    CALL TR_SETATTRIBUTE(window.show,403,'TRAT_Disabled',1)
  702.    CALL TR_SETATTRIBUTE(window.show,405,'TRAT_Disabled',1)
  703.    CALL TR_SETATTRIBUTE(window.show,406,'TRAT_Disabled',1)
  704.    CALL TR_SETATTRIBUTE(window.show,407,'TRAT_Disabled',1)
  705.    CALL TR_SETATTRIBUTE(window.show,402,'TRAT_Text','Contacting host...')
  706.    CALL TR_SETATTRIBUTE(window.show,404,'TRAT_Disabled',0)
  707.  
  708.    CALL getdata
  709.  
  710.    CALL TR_SETATTRIBUTE(window.show,403,'TROB_String',url)
  711.    CALL TR_SETATTRIBUTE(window.show,403,'TRAT_Disabled',0)
  712.    CALL TR_SETATTRIBUTE(window.show,405,'TRAT_Disabled',0)
  713.    CALL TR_SETATTRIBUTE(window.show,406,'TRAT_Disabled',0)
  714.    CALL TR_SETATTRIBUTE(window.show,407,'TRAT_Disabled',0)
  715.    CALL TR_SETATTRIBUTE(window.show,404,'TRAT_Disabled',1)
  716.  
  717.    stoploop.show=0
  718.    SELECT
  719.       WHEN success   THEN CALL TR_SETATTRIBUTE(window.show,402,'TRAT_Text',infotextadd'Now showing' COMPRESS(pagetitle,asterisk)'.')
  720.       WHEN retry=703 THEN CALL TR_SETATTRIBUTE(window.show,402,'TRAT_Text','Could not get' url'.')
  721.       WHEN retry=702 THEN DO
  722.          CALL browse(url)
  723.          CALL TR_SETATTRIBUTE(window.show,402,'TRAT_Text','Could not get' url'. Tried browse.')
  724.       END
  725.       OTHERWISE NOP
  726.    END
  727. RETURN 0
  728.  
  729.  
  730.  
  731. /*** internal list handling ***/
  732.  
  733.  
  734.  
  735. new:
  736.    CALL TR_LOCKPROJECT(window.main)
  737.  
  738.    button2  ='a_dd anyway'
  739.    button3  ='_abort'
  740.    showpage =0
  741.    listfails=0
  742.  
  743.    stoploop.new=0
  744.    window.new  =TR_OPENPROJECT(app,taglist.new)
  745.    DO UNTIL stoploop.new
  746.       CALL TR_WAIT(app,'')
  747.       DO WHILE TR_HANDLEMSG(app,'event')
  748.          IF event.trm_class='TRMS_CLOSEWINDOW' THEN stoploop.new=1
  749.          IF event.trm_class='TRMS_ACTION' THEN DO
  750.             IF event.trm_id=503 THEN stoploop.new=1
  751.             IF event.trm_id=502 THEN DO
  752.                name        ='  (????)' TR_GETATTRIBUTE(window.new,511,'TROB_String')
  753.                IF TR_GETATTRIBUTE(window.new,513,'TRAT_Value') THEN name=OVERLAY('fsze',name,4)
  754.                url         =encodeurl(TR_GETATTRIBUTE(window.new,512,'TROB_String'))
  755.                vurl        =encodeurl(TR_GETATTRIBUTE(window.new,514,'TROB_String'))
  756.                inputurl    =url
  757.                stoploop.new=1
  758.  
  759.                CALL TR_LOCKPROJECT(window.new)
  760.                CALL getdata
  761.                IF success | retry=702 THEN DO
  762.                   IF retry=702 THEN data='unverified'
  763.                   number=oldlist.0+1
  764.  
  765.                   oldlist.number=name
  766.                   IF SUBSTR(name,4,4)~='fsze' THEN SELECT
  767.                      WHEN data='unverified'  THEN oldlist.number=OVERLAY('????',name,4)
  768.                      WHEN DATATYPE(data,'N') THEN oldlist.number=OVERLAY('size',name,4)
  769.                      OTHERWISE oldlist.number=OVERLAY('date',name,4)
  770.                   END
  771.  
  772.                   oldlist.number.urlstring =inputurl' 'vurl
  773.                   oldlist.number.datastring=data
  774.                   oldlist.0                =number
  775.  
  776.                   modified=1
  777.                   CALL redrawlists
  778.                END
  779.                ELSE stoploop.new=0
  780.                CALL TR_UNLOCKPROJECT(window.new)
  781.             END
  782.          END
  783.       END
  784.    END
  785.    CALL TR_CLOSEPROJECT(window.new)
  786.  
  787.    CALL TR_UNLOCKPROJECT(window.main)
  788. RETURN 0
  789.  
  790.  
  791.  
  792. delete:
  793.    number=TR_GETATTRIBUTE(window.main,101,'TRAT_Value')+1
  794.  
  795.    IF oldlist.0>0 THEN DO
  796.       DO i=number WHILE i<oldlist.0
  797.          o=i+1
  798.          oldlist.i           =oldlist.o
  799.          oldlist.i.urlstring =oldlist.o.urlstring
  800.          oldlist.i.datastring=oldlist.o.datastring
  801.       END
  802.       oldlist.0=oldlist.0-1
  803.  
  804.       modified=1
  805.       CALL redrawlists
  806.    END
  807. RETURN 0
  808.  
  809.  
  810.  
  811. forget:
  812.    number=TR_GETATTRIBUTE(window.main,102,'TRAT_Value')+1
  813.  
  814.    IF newlist.0>0 THEN DO
  815.       DO i=number WHILE i<newlist.0
  816.          o=i+1
  817.          newlist.i           =newlist.o
  818.          newlist.i.urlstring =newlist.o.urlstring
  819.          newlist.i.datastring=newlist.o.datastring
  820.       END
  821.       newlist.0=newlist.0-1
  822.  
  823.       modified=1
  824.       CALL redrawlists
  825.    END
  826. RETURN 0
  827.  
  828.  
  829.  
  830. getinfo:
  831.    number=TR_GETATTRIBUTE(window.main,100+ARG(1),'TRAT_Value')+1
  832.  
  833.    IF ARG(1)=1 THEN DO
  834.       name=oldlist.number
  835.  
  836.       url =WORD(oldlist.number.urlstring,1)
  837.       vurl=WORD(oldlist.number.urlstring,2)
  838.  
  839.       PARSE VAR oldlist.number.urlstring url' 'vurl
  840.       data=oldlist.number.datastring
  841.    END
  842.    ELSE DO
  843.       name=newlist.number
  844.       url =WORD(newlist.number.urlstring,1)
  845.       vurl=WORD(newlist.number.urlstring,2)
  846.       data=newlist.number.datastring
  847.    END
  848. RETURN 0
  849.  
  850.  
  851.  
  852. /*** listfile handling ***/
  853.  
  854.  
  855.  
  856. readlistfile:
  857.    reportmsg='Listfile' progdir'Upd8.locations is corrupt.'
  858.  
  859.    IF EXISTS(progdir'Upd8.locations') THEN DO
  860.       IF ~OPEN('listfile',progdir'Upd8.locations','R') THEN CALL report(1,'Unable to open' progdir'Upd8.locations for reading.')
  861.       IF READLN('listfile')~=='Upd8 - locations' THEN CALL report
  862.  
  863.       count   =0
  864.       newcount=0
  865.  
  866.       DO UNTIL EOF('listfile')
  867.          temp=READLN('listfile')
  868.          IF temp~='' THEN DO
  869.             IF WORD(temp,1)='NAME' THEN DO
  870.                count=count+1
  871.                oldlist.count='  'SUBWORD(temp,2)
  872.                temp=READLN('listfile')
  873.                IF WORD(temp,1)='URL' THEN DO
  874.                   oldlist.count.urlstring=SUBSTR(temp,6)
  875.                   temp=READLN('listfile')
  876.                   IF WORD(temp,1)='DATA' THEN DO
  877.                      oldlist.count.datastring=SUBWORD(temp,2)
  878.                   END
  879.                   ELSE CALL report
  880.                END
  881.                ELSE CALL report
  882.             END
  883.             ELSE IF WORD(temp,1)='NEW' THEN DO
  884.                newcount=newcount+1
  885.                newlist.newcount='  'SUBWORD(temp,2)
  886.                temp=READLN('listfile')
  887.                IF WORD(temp,1)='URL' THEN DO
  888.                   newlist.newcount.urlstring=SUBSTR(temp,6)
  889.                   temp=READLN('listfile')
  890.                   IF WORD(temp,1)='DATA' THEN DO
  891.                      newlist.newcount.datastring=SUBWORD(temp,2)
  892.                   END
  893.                   ELSE CALL report
  894.                END
  895.                ELSE CALL report
  896.             END
  897.             ELSE CALL report
  898.          END
  899.       END
  900.       oldlist.0=count
  901.       newlist.0=newcount
  902.       CALL CLOSE('listfile')
  903.    END
  904.    ELSE CALL defaultlist
  905. RETURN 0
  906.  
  907.  
  908.  
  909. defaultlist:
  910.    oldlist.1           ='  (????) Turbid design'
  911.    oldlist.1.urlstring ='http://home.swipnet.se/turbid/modified.txt http://home.swipnet.se/turbid/'
  912.    oldlist.1.datastring='unverified'
  913.    oldlist.0           =1
  914. RETURN 0
  915.  
  916.  
  917.  
  918. writelistfile:
  919.    IF ~modified THEN RETURN 0
  920.    IF ~OPEN('listfile',progdir'Upd8.locations','W') THEN DO
  921.       CALL report(0,'Unable to open' progdir'Upd8.locations for writing.')
  922.       RETURN 0
  923.    END
  924.  
  925.    bigstring='Upd8 - locations'lf
  926.    delay=30
  927.    DO i=1 TO oldlist.0
  928.       bigstring=bigstring||lf'NAME 'SUBSTR(oldlist.i,3)||lf'URL  'oldlist.i.urlstring||lf'DATA 'oldlist.i.datastring||lf
  929.       IF i>delay THEN DO
  930.          CALL WRITECH('listfile',bigstring)
  931.          bigstring=''
  932.          delay=delay+30
  933.       END
  934.    END
  935.    DO i=1 TO newlist.0
  936.       bigstring=bigstring||lf'NEW  'SUBSTR(newlist.i,3)||lf'URL  'newlist.i.urlstring||lf'DATA 'newlist.i.datastring||lf
  937.       IF i>delay THEN DO
  938.          CALL WRITECH('listfile',bigstring)
  939.          bigstring=''
  940.          delay=delay+30
  941.       END
  942.    END
  943.    CALL WRITECH('listfile',bigstring)
  944.    CALL CLOSE('listfile')
  945. RETURN 0
  946.  
  947.  
  948.  
  949. importbookcon:
  950.    IF ~ASL_REQUESTFILE(window.main,'bookconfile',LoadFileP('Upd8 - select BookCon text file','Import',progdir,'Hotlist.txt','#?.txt')) THEN RETURN 0
  951.  
  952.    CALL TR_LOCKPROJECT(window.main)
  953.    count=oldlist.0
  954.    IF markimported THEN prefix='> '
  955.    ELSE prefix='  '
  956.  
  957.    IF ~OPEN('bookconfile',bookconfile.1,'R') THEN DO
  958.       CALL report(0,'Could not open BookCon text file 'bookconfile.1'.')
  959.       CALL TR_UNLOCKPROJECT(window.main)
  960.       RETURN 0
  961.    END
  962.  
  963.    IF POS('BookCon',READLN('bookconfile')||READLN('bookconfile')||READLN('bookconfile'))<1 THEN DO
  964.       CALL report(0,bookconfile.1' is not a BookCon text file.')
  965.       CALL TR_UNLOCKPROJECT(window.main)
  966.       CALL CLOSE('bookconfile')
  967.       RETURN 0
  968.    END
  969.  
  970.    DO UNTIL EOF('bookconfile')
  971.       temp=READLN('bookconfile')
  972.       IF SUBSTR(temp,1,6)=='Name: ' THEN DO
  973.          count        =count+1
  974.          oldlist.count=prefix'(????) 'STRIP(SUBSTR(temp,7))
  975.          temp         =READLN('bookconfile')
  976.          IF SUBSTR(temp,1,6)=='URL : ' THEN DO
  977.             oldlist.count.urlstring =encodeurl(SUBSTR(temp,7))
  978.             oldlist.count.datastring='unverified'
  979.          END
  980.          ELSE DO
  981.             CALL report(0,'BookCon text file 'bookconfile.1' is corrupt.')
  982.             CALL TR_UNLOCKPROJECT(window.main)
  983.             CALL CLOSE('bookconfile')
  984.             RETURN 0
  985.          END
  986.       END
  987.    END
  988.  
  989.    CALL CLOSE('bookconfile')
  990.    IF oldlist.0<count THEN modified=1
  991.    oldlist.0=count
  992.    CALL redrawlists
  993.    CALL TR_UNLOCKPROJECT(window.main)
  994. RETURN 0
  995.  
  996.  
  997.  
  998. /*** prefsfile handling ***/
  999.  
  1000.  
  1001.  
  1002. readprefsfile:
  1003.    reportmsg='Prefsfile' progdir'Upd8.prefs is corrupt.'
  1004.    CALL defaultprefs
  1005.  
  1006.    IF EXISTS(progdir'Upd8.prefs') THEN DO
  1007.       IF ~OPEN('prefsfile',progdir'Upd8.prefs','R') THEN CALL report(1,'Unable to open' progdir'Upd8.prefs for reading.')
  1008.       IF READLN('prefsfile')~=='Upd8 - preferences' THEN CALL report
  1009.  
  1010.       DO UNTIL EOF('prefsfile')
  1011.          temp   =READLN('prefsfile')
  1012.          keyword=WORD(temp,1)
  1013.          content=SUBWORD(temp,2)
  1014.          SELECT
  1015.             WHEN keyword=''              THEN NOP
  1016.             WHEN keyword='STARTCHECK'    THEN startcheck   =content
  1017.             WHEN keyword='ERRORCONTINUE' THEN errorcontinue=content
  1018.             WHEN keyword='NOTIFYREADY'   THEN notifyready  =content
  1019.             WHEN keyword='BROWSER'       THEN browser      =content
  1020.             WHEN keyword='TEXTWIDTH'     THEN textwidth    =content
  1021.             WHEN keyword='TIMEOUT'       THEN timeout      =content
  1022.             WHEN keyword='THRESHOLD'     THEN threshold    =content
  1023.             WHEN keyword='MARKIMPORTED'  THEN markimported =content
  1024.             OTHERWISE CALL report
  1025.          END
  1026.       END
  1027.  
  1028.       CALL CLOSE('prefsfile')
  1029.    END
  1030. RETURN 0
  1031.  
  1032.  
  1033.  
  1034. defaultprefs:
  1035.    startcheck   =0
  1036.    errorcontinue=1
  1037.    notifyready  =1
  1038.    markimported =1
  1039.    browser      =''
  1040.    textwidth    =60
  1041.    timeout      =20
  1042.    threshold    =12
  1043. RETURN 0
  1044.  
  1045.  
  1046.  
  1047. writeprefsfile:
  1048.    IF ~OPEN('prefsfile',progdir'Upd8.prefs','W') THEN DO
  1049.       CALL report(0,'Unable to open' progdir'Upd8.prefs for writing.')
  1050.       RETURN 0
  1051.    END
  1052.  
  1053.    CALL WRITELN('prefsfile','Upd8 - preferences'lf||lf'STARTCHECK    'startcheck||lf'ERRORCONTINUE 'errorcontinue||lf'NOTIFYREADY   'notifyready||lf'BROWSER       'browser||lf'TEXTWIDTH     'textwidth||lf'TIMEOUT       'timeout||lf'THRESHOLD     'threshold||lf'MARKIMPORTED  'markimported)
  1054.    CALL CLOSE('prefsfile')
  1055. RETURN 0
  1056.  
  1057.  
  1058.  
  1059. /*** file verifying ***/
  1060.  
  1061.  
  1062.  
  1063. check:
  1064.    CALL TR_LOCKPROJECT(window.main)
  1065.    CALL TR_SETATTRIBUTE(window.main,103,'TRAT_Value',0)
  1066.    CALL TR_SETATTRIBUTE(window.main,103,'TROB_Progress',oldlist.0)
  1067.  
  1068.    button2      ='a_bort all'
  1069.    button3      ='_abort'
  1070.    showpage     =0
  1071.    progress     =0
  1072.    listfails    =0
  1073.    fails.0      =0
  1074.    multicheck   =0
  1075.    markedcheck  =(ARG(1)='MARKED')
  1076.    oldlistlength=newlist.0
  1077.  
  1078.    IF ARG(1,'O') | markedcheck THEN DO
  1079.       multicheck   =1
  1080.       continuecheck=1
  1081.       IF markedcheck THEN infotextadd='Verified marked. '
  1082.       ELSE infotextadd='Verified all. '
  1083.       IF errorcontinue THEN DO
  1084.          listfails=1
  1085.          fails.0  =0
  1086.       END
  1087.       DO number=1 WHILE number<=oldlist.0 & continuecheck
  1088.          IF markedcheck & SUBSTR(oldlist.number,1,1)=' ' THEN ITERATE
  1089.          name=oldlist.number
  1090.          url =WORD(oldlist.number.urlstring,1)
  1091.          data=oldlist.number.datastring
  1092.          CALL TR_SETATTRIBUTE(window.main,110,'TRAT_Text','Verifying' SUBSTR(name,4,4) 'of' SUBSTR(name,10)'...')
  1093.          olddata=data; oldurl=url
  1094.          CALL getdata
  1095.          IF listfails THEN DO
  1096.             IF success THEN oldlist.number=OVERLAY(' ',oldlist.number)
  1097.             ELSE DO
  1098.                oldlist.number=OVERLAY('> ',oldlist.number)
  1099.                fails.0       =1+fails.0
  1100.                temp          =fails.0
  1101.                fails.temp    =SUBSTR(oldlist.number,3)' ('failreason')'
  1102.             END
  1103.             CALL TR_SETATTRIBUTE(window.main,101,'TROB_Listview','oldlist')
  1104.          END
  1105.          IF retry=702 THEN continuecheck=0
  1106.          IF success THEN CALL verifychange
  1107.          ELSE infotextadd='Partial verification. '
  1108.          progress=progress+1
  1109.          CALL TR_SETATTRIBUTE(window.main,103,'TRAT_Value',progress)
  1110.       END
  1111.       IF newlist.0>oldlistlength THEN infotext=infotextadd||newlist.0-oldlistlength 'updates found.'
  1112.       ELSE infotext=infotextadd'No updates found.'
  1113.       IF newlist.0=oldlistlength+1 THEN infotext=infotextadd'1 update found.'
  1114.    END
  1115.    ELSE DO
  1116.       progress=oldlist.0
  1117.       number=ARG(1)
  1118.       name=oldlist.number
  1119.       url =WORD(oldlist.number.urlstring,1)
  1120.       data=oldlist.number.datastring
  1121.       CALL TR_SETATTRIBUTE(window.main,110,'TRAT_Text','Verifying' SUBSTR(name,4,4) 'of' SUBSTR(name,10)'...')
  1122.       olddata=data; oldurl=url
  1123.       CALL getdata
  1124.       IF success THEN DO
  1125.          CALL verifychange
  1126.          IF newlist.0>oldlistlength THEN infotext=SUBSTR(name,10) 'is updated.'
  1127.          ELSE infotext=SUBSTR(name,10) 'is not updated.'
  1128.       END
  1129.       ELSE infotext='Failed to verify' SUBSTR(name,10)'.'
  1130.    END
  1131.  
  1132.    CALL TR_SETATTRIBUTE(window.main,103,'TRAT_Value',progress)
  1133.    CALL TR_SETATTRIBUTE(window.main,110,'TRAT_Text',infotext)
  1134.    CALL TR_UNLOCKPROJECT(window.main)
  1135.  
  1136.    IF fails.0>0 THEN DO
  1137.       IF failsopen THEN DO
  1138.          CALL TR_SETATTRIBUTE(window.failslist,901,'TROB_Listview','fails')
  1139.          CALL TR_SETATTRIBUTE(window.failslist,903,'TRAT_Text',infotext)
  1140.          IF notifyready THEN DO
  1141.             CALL PROJECTTOFRONT(window.failslist)
  1142.             CALL ACTIVATEPROJECT(window.failslist)
  1143.          END
  1144.       END
  1145.       ELSE DO
  1146.          taglist=WindowID(9),
  1147.             PubScreenName('Workbench'),
  1148.             WindowPosition('TRWP_CENTERDISPLAY'),
  1149.             WindowTitle('Upd8 - verification failures'),
  1150.             'VertGroupA',
  1151.                'HorizGroupA',
  1152.                   ListRO('fails',901,0) 'TRAT_MinHeight 4',
  1153.                'EndGroup',
  1154.                'SpaceS',
  1155.                'HorizGroupA',
  1156.                   'SpaceS',
  1157.                   ClippedTextID(infotext,903) 'TRAT_Flags TRTX_NOUNDERSCORE',
  1158.                   'SpaceS',
  1159.                'EndGroup',
  1160.                'SpaceS',
  1161.                'HorizGroupA',
  1162.                   ButtonR('_close',902),
  1163.                'EndGroup',
  1164.             'EndGroup',
  1165.          'EndProject'
  1166.  
  1167.          window.failslist=TR_OPENPROJECT(app,taglist)
  1168.          IF window.failslist=null THEN CALL report(0,'Could not open fails list window.')
  1169.          ELSE failsopen=1
  1170.       END
  1171.    END
  1172.    ELSE IF multicheck & notifyready THEN DO
  1173.       IF failsopen THEN DO
  1174.          CALL TR_CLOSEPROJECT(window.failslist)
  1175.          failsopen=0
  1176.       END
  1177.       CALL report(0, infotext)
  1178.    END
  1179. RETURN 0
  1180.  
  1181.  
  1182.  
  1183. verifychange:
  1184.    oldmethod=SUBSTR(name,4,4)
  1185.    IF oldmethod='fsze' THEN method='fsze'
  1186.    ELSE DO
  1187.       IF DATATYPE(data,'N') THEN method='size'
  1188.       ELSE method='date'
  1189.    END
  1190.  
  1191.    IF oldmethod~=method | olddata='unverified' THEN DO
  1192.       modified                 =1
  1193.       oldlist.number           =OVERLAY(method,oldlist.number,4)
  1194.       oldlist.number.datastring=data
  1195.       IF oldmethod~='????' & olddata~='unverified' THEN DO
  1196.          CALL updated
  1197.          newlist.x=newlist.x' (method changed)'
  1198.       END
  1199.       CALL redrawlists
  1200.    END
  1201.    ELSE IF olddata~=data THEN CALL newdata
  1202. RETURN 0
  1203.  
  1204.  
  1205.  
  1206. newdata:
  1207.    modified=1
  1208.    IF method='size' | method='fsze' THEN DO
  1209.       IF ~DATATYPE(olddata,'N') THEN olddata=data
  1210.       IF ABS(data-olddata)<threshold THEN DO
  1211.          oldlist.number.datastring=data
  1212.          RETURN 0
  1213.       END
  1214.    END
  1215.  
  1216.    oldlist.number.datastring=data
  1217.    CALL updated
  1218.    IF DATATYPE(data,'N') THEN DO
  1219.       IF data-olddata>0 THEN prefix='+'
  1220.       ELSE prefix=''
  1221.       newlist.x=newlist.x '('prefix||data-olddata 'bytes)'
  1222.    END
  1223.    CALL redrawlists
  1224. RETURN 0
  1225.  
  1226.  
  1227.  
  1228. updated:
  1229.    IF multicheck & newlist.0>0 & newlist.0=oldlistlength THEN DO
  1230.       newlist.0    =newlist.0+1
  1231.       x            =newlist.0
  1232.       oldlistlength=oldlistlength+1
  1233.  
  1234.       newlist.x           ='  (date) ----------------------------------------------------------------'
  1235.       newlist.x.urlstring ='http://home.swipnet.se/turbid/separator.txt'
  1236.       newlist.x.datastring='unverified'
  1237.    END
  1238.  
  1239.    newlist.0           =newlist.0+1
  1240.    x                   =newlist.0
  1241.    newlist.x           =OVERLAY(' ',oldlist.number)
  1242.    newlist.x.urlstring =oldlist.number.urlstring
  1243.    newlist.x.datastring=data
  1244. RETURN 0
  1245.  
  1246.  
  1247.  
  1248. getdata:
  1249.    redirect=0
  1250.    DO UNTIL retry=703 | retry=702
  1251.       retry     =703
  1252.       closesock =0
  1253.       success   =0
  1254.       failreason='Reason unknown.'
  1255.  
  1256.       CALL recieve
  1257.       IF closesock THEN CALL CLOSESOCKET(sock)
  1258.       IF ~success & redirected THEN redirect=redirect-1
  1259.  
  1260.       IF ~success & ~listfails THEN DO
  1261.          taglist=WindowID(7),
  1262.             PubScreenName('Workbench'),
  1263.             WindowPosition('TRWP_CENTERDISPLAY'),
  1264.             WindowTitle('Upd8 - get location'),
  1265.             'VertGroupA',
  1266.                'HorizGroupA',
  1267.                   'SpaceS',
  1268.                   'VertGroupA',
  1269.                      'SpaceS',
  1270.                      TextN('Could not get location:'),
  1271.                      'SpaceS',
  1272.                      'LineArray',
  1273.                         'Beginline',
  1274.                            TextNR('name:'),
  1275.                            'SpaceS',
  1276.                            TextN(COMPRESS(SUBSTR(name,10),asterisk)) 'TRAT_Flags TRTX_NOUNDERSCORE',
  1277.                         'EndLine',
  1278.                         'BeginLine',
  1279.                            TextNR('URL:'),
  1280.                            'SpaceS',
  1281.                            TextN(url) 'TRAT_Flags TRTX_NOUNDERSCORE',
  1282.                         'EndLine',
  1283.                      'EndArray',
  1284.                      'SpaceS',
  1285.                      TextN(failreason),
  1286.                      'SpaceS',
  1287.                   'EndGroup',
  1288.                   'SpaceS',
  1289.                'EndGroup',
  1290.                'HorizGroupA',
  1291.                   ButtonR('_retry',701),
  1292.                   Button(button2,702),
  1293.                   ButtonE(button3,703),
  1294.                'EndGroup',
  1295.             'EndGroup',
  1296.          'EndProject'
  1297.  
  1298.          retry=TR_AUTOREQUEST(app,null,taglist)
  1299.          IF retry=0 THEN DO
  1300.             report(0,'Verify failed. Requester failed. Aborted.')
  1301.             retry=703
  1302.          END
  1303.       END
  1304.    END
  1305. RETURN 0
  1306.  
  1307.  
  1308.  
  1309. recieve:
  1310.    redirected=0
  1311.    IF ~parseurl() THEN RETURN 0
  1312.  
  1313.    DO WHILE statuscode>299 & statuscode<400
  1314.       redirected=1
  1315.       redirect  =redirect+1
  1316.       IF redirect>5 THEN DO
  1317.          failreason='More than five redirections, probably looping.'
  1318.          RETURN 0
  1319.       END
  1320.       DO UNTIL ABBREV(UPPER(line),'LOCATION:')
  1321.          IF ~getline() THEN RETURN 0
  1322.          IF line='' THEN DO
  1323.             failreason='Bad redirection header.'
  1324.             RETURN 0
  1325.          END
  1326.       END
  1327.       PARSE VAR line .' 'newurl
  1328.  
  1329.       IF ABBREV(UPPER(newurl),'HTTP://') THEN url=newurl
  1330.       ELSE DO
  1331.          IF SUBSTR(newurl,1,1)='/' THEN DO
  1332.             PARSE VAR url 8 host'/'file
  1333.             url='http://'host||newurl
  1334.          END
  1335.          ELSE DO
  1336.             PARSE VAR url url'?'
  1337.             lastslash=LASTPOS('/',url)+1
  1338.             PARSE VAR url url =lastslash
  1339.             url=url||newurl
  1340.          END
  1341.       END
  1342.       redirected=0
  1343.       IF ~parseurl() THEN RETURN 0
  1344.    END
  1345.  
  1346.    IF statuscode~=200 THEN DO
  1347.       failreason='Server replied:' statuscode statusphrase
  1348.       RETURN 0
  1349.    END
  1350.  
  1351.    mime     =''
  1352.    data     =''
  1353.    nodate   =1
  1354.    position =1
  1355.    forcesize=(SUBSTR(name,4,4)='fsze')
  1356.    DO UNTIL field=''
  1357.       IF ~getline() THEN RETURN 0
  1358.       PARSE VAR line field': 'content
  1359.       field=UPPER(field)
  1360.       SELECT
  1361.          WHEN field='LAST-MODIFIED' & ~forcesize THEN DO
  1362.             nodate=0
  1363.             data  =content
  1364.          END
  1365.          WHEN field='CONTENT-LENGTH' & nodate THEN DO
  1366.             nodate=0
  1367.             data  =content
  1368.          END
  1369.          WHEN field='CONTENT-TYPE' THEN mime=content
  1370.          OTHERWISE NOP
  1371.       END
  1372.    END
  1373.  
  1374.    IF showpage THEN DO
  1375.       IF mime~='text/html' & mime~='text/plain' THEN DO
  1376.          failreason='Filetype' mime 'unknown.'
  1377.          RETURN 0
  1378.       END
  1379.  
  1380.       CALL TR_SETATTRIBUTE(window.show,402,'TRAT_Text','Recieving and formatting as 'mime'...')
  1381.  
  1382.       buffer      =''
  1383.       tagpart     =''
  1384.       bufferlength=0
  1385.       datalength  =1
  1386.       count       =0
  1387.  
  1388.       IF mime='text/html'  THEN CALL formathtml
  1389.       IF mime='text/plain' THEN CALL formattext
  1390.  
  1391.       linelist.0=count
  1392.       topline=TR_GETATTRIBUTE(window.show,401,'TRLV_Top')
  1393.       CALL TR_SETATTRIBUTE(window.show,401,'TROB_Listview','linelist')
  1394.       CALL TR_SETATTRIBUTE(window.show,401,'TRLV_Top',topline)
  1395.    END
  1396.    ELSE DO
  1397.       IF nodate THEN DO
  1398.          filelength=0
  1399.          DO UNTIL datalength=0
  1400.             datalength=RECV(sock,'DATA',4096)
  1401.             IF datalength=-1 THEN DO
  1402.                failreason='Recieve failed.'
  1403.                RETURN 0
  1404.             END
  1405.             filelength=filelength+datalength
  1406.          END
  1407.          data=filelength
  1408.       END
  1409.    END
  1410.  
  1411.    success=1
  1412. RETURN 0
  1413.  
  1414.  
  1415.  
  1416. parseurl:
  1417.    IF closesock THEN CALL CLOSESOCKET(sock)
  1418.    closesock=0
  1419.  
  1420.    newurl=STRIP(url)
  1421.    PARSE VAR newurl newurl'?'arguments
  1422.    IF ~ABBREV(UPPER(newurl),'HTTP://') THEN DO
  1423.       IF POS('://',newurl)>0 THEN DO
  1424.          failreason='Not a HTTP URL.'
  1425.          RETURN 0
  1426.       END
  1427.       newurl='http://'newurl
  1428.    END
  1429.    IF POS('/',newurl,8)<1 THEN newurl=newurl'/'
  1430.  
  1431.    PARSE VAR newurl 8 host'/'file
  1432.    file='/'file
  1433.    PARSE VAR host host':'port
  1434.    IF port='' THEN port=80
  1435.  
  1436.    IF ~DATATYPE(port,'N') THEN DO
  1437.       failreason='Bad HTTP URL.'
  1438.       RETURN 0
  1439.    END
  1440.  
  1441.    IF arguments='' THEN url=newurl
  1442.    ELSE DO
  1443.       url =newurl'?'arguments
  1444.       file=file'?'arguments
  1445.    END
  1446.  
  1447.    IF ~ISLIBON('SOCKET') THEN DO
  1448.       failreason='No TCP/IP stack available.'
  1449.       RETURN 0
  1450.    END
  1451.    sock=SOCKET('INET','STREAM')
  1452.    IF sock=-1 THEN DO
  1453.       failreason='Could not obtain socket.'
  1454.       RETURN 0
  1455.    END
  1456.    closesock=1
  1457.  
  1458.    x.ADDRPORT  =port
  1459.    x.ADDRFAMILY='INET'
  1460.    x.ADDRADDR  =RESOLVE(host)
  1461.    IF x.ADDRADDR=-1 THEN DO
  1462.       failreason='Unknown host.'
  1463.       RETURN 0
  1464.    END
  1465.  
  1466.    CALL SETSOCKOPT(sock,"SOCKET","RCVTIMEO",timeout)
  1467.    CALL SETSOCKOPT(sock,"SOCKET","SNDTIMEO",timeout)
  1468.    IF CONNECT(sock,'X')<0 THEN DO
  1469.       failreason='Connection failed.'
  1470.       RETURN 0
  1471.    END
  1472.    IF SEND(sock,'GET' file 'HTTP/1.0'crlf'User-Agent: Upd8/'version '(AmigaOS)'crlf'Host:' host||crlf'Pragma: no-cache'crlf||crlf)<0 THEN DO
  1473.       failreason='Request failed.'
  1474.       RETURN 0
  1475.    END
  1476.  
  1477.    IF ~getline() THEN RETURN 0
  1478.  
  1479.    IF ABBREV(line,'HTTP/') THEN DO
  1480.       PARSE VAR line 'HTTP/' . ' 'statuscode' 'statusphrase
  1481.       IF ~DATATYPE(statuscode,'N')  THEN DO
  1482.          failreason='Bad HTTP response.'
  1483.          RETURN 0
  1484.       END
  1485.    END
  1486.    ELSE DO
  1487.       statuscode  =200
  1488.       statusphrase='Fine.'
  1489.    END
  1490. RETURN 1
  1491.  
  1492.  
  1493.  
  1494. getline:
  1495.    IF RECVLINE(sock,'LINE',1024)<1 THEN DO
  1496.       failreason='Recieve failed.'
  1497.       RETURN 0
  1498.    END
  1499.    line=COMPRESS(line,crlf)
  1500. RETURN 1
  1501.  
  1502.  
  1503.  
  1504. moredata:
  1505.    DO WHILE TR_HANDLEMSG(app,'event')
  1506.       IF (event.trm_class='TRMS_ACTION' & event.trm_id=404) | event.trm_class='TRMS_CLOSEWINDOW' THEN DO
  1507.          infotextadd='Transfer aborted. '
  1508.          RETURN 0
  1509.       END
  1510.    END
  1511.  
  1512.    linelist.0=count
  1513.    topline   =TR_GETATTRIBUTE(window.show,401,'TRLV_Top')
  1514.    CALL TR_SETATTRIBUTE(window.show,401,'TROB_Listview','linelist')
  1515.    CALL TR_SETATTRIBUTE(window.show,401,'TRLV_Top',topline)
  1516.  
  1517.    datalength=RECV(sock,'DATA',4096)
  1518.    IF datalength=-1 THEN DO
  1519.       infotextadd='Transfer interrupted. '
  1520.       RETURN 0
  1521.    END
  1522.    buffer =buffer||tagpart||TRANSLATE(COMPRESS(data,removechars),' ',tab)
  1523.    tagpart=''
  1524. RETURN 1
  1525.  
  1526.  
  1527.  
  1528. formathtml:
  1529.    removechars=crlf
  1530.    DO UNTIL (bufferlength=0 & datalength=0)
  1531.       IF bufferlength<=textwidth & datalength>0 THEN DO
  1532.          IF ~moredata() THEN RETURN 0
  1533.          CALL htmltags
  1534.       END
  1535.  
  1536.       bufferlength=LENGTH(buffer)
  1537.       breakpoint  =POS(lf,buffer)
  1538.       IF breakpoint>textwidth | (breakpoint=0 & bufferlength>textwidth) THEN DO
  1539.          breakpoint=LASTPOS(' ',buffer,textwidth)
  1540.          IF breakpoint=0 THEN breakpoint=textwidth
  1541.       END
  1542.       IF datalength=0 & breakpoint=0 & bufferlength<=textwidth THEN breakpoint=bufferlength
  1543.  
  1544.       count         =count+1
  1545.       linelist.count=COMPRESS(SUBSTR(buffer,1,breakpoint),lf)
  1546.       buffer        =SUBSTR(buffer,breakpoint+1)
  1547.       bufferlength  =LENGTH(buffer)
  1548.    END
  1549. RETURN 0
  1550.  
  1551.  
  1552.  
  1553. formattext:
  1554.    removechars=cr
  1555.    pagetitle  ='plain text'
  1556.    DO UNTIL (bufferlength=0 & datalength=0)
  1557.       IF bufferlength<=textwidth & datalength>0 THEN DO
  1558.          IF ~moredata() THEN RETURN 0
  1559.       END
  1560.  
  1561.       bufferlength=LENGTH(buffer)
  1562.       breakpoint  =POS(lf,buffer)
  1563.       IF breakpoint>textwidth | (breakpoint=0 & bufferlength>textwidth) THEN DO
  1564.          breakpoint=LASTPOS(' ',buffer,textwidth)
  1565.          IF breakpoint=0 THEN breakpoint=textwidth
  1566.       END
  1567.       IF datalength=0 & breakpoint=0 & bufferlength<=textwidth THEN breakpoint=bufferlength
  1568.  
  1569.       count         =count+1
  1570.       linelist.count=COMPRESS(SUBSTR(buffer,1,breakpoint),lf)
  1571.       buffer        =SUBSTR(buffer,breakpoint+1)
  1572.       bufferlength  =LENGTH(buffer)
  1573.    END
  1574. RETURN 0
  1575.  
  1576.  
  1577.  
  1578. htmltags:
  1579.    position=0
  1580.    taglength=0
  1581.    DO UNTIL position=0 | taglength<2; position=POS('&',buffer,position+1)
  1582.       IF position>0 THEN DO; taglength=POS(';',buffer,position+1)-position+1
  1583.          IF taglength>1 & taglength<10 THEN DO
  1584.             tag        =SUBSTR(buffer,position+1,taglength-2)
  1585.             replacement='?'
  1586.             SELECT
  1587.                WHEN POS('#X',UPPER(tag)) THEN IF DATATYPE(SUBSTR(tag,3),'X') THEN replacement=X2C(SUBSTR(tag,3))
  1588.                WHEN POS('#',UPPER(tag)) THEN IF DATATYPE(SUBSTR(tag,2),'N') THEN replacement=D2C(SUBSTR(tag,2))
  1589.                OTHERWISE SELECT
  1590.                   WHEN tag='nbsp'  THEN replacement=' '
  1591.                   WHEN tag='copy'  THEN replacement='©'
  1592.                   WHEN tag='reg'   THEN replacement='®'
  1593.                   WHEN tag='szlig' THEN replacement='ß'
  1594.                   WHEN tag='quot'  THEN replacement='"'
  1595.                   WHEN tag='amp'   THEN replacement='&'
  1596.                   WHEN tag='lt'    THEN replacement='<'
  1597.                   WHEN tag='gt'    THEN replacement='>'
  1598.  
  1599.                   WHEN tag='uuml'  THEN replacement='ü'
  1600.                   WHEN tag='aring' THEN replacement='å'
  1601.                   WHEN tag='auml'  THEN replacement='ä'
  1602.                   WHEN tag='ouml'  THEN replacement='ö'
  1603.  
  1604.                   WHEN tag='Uuml'  THEN replacement='Ü'
  1605.                   WHEN tag='Aring' THEN replacement='Å'
  1606.                   WHEN tag='Auml'  THEN replacement='Ä'
  1607.                   WHEN tag='Ouml'  THEN replacement='Ö'
  1608.                   OTHERWISE NOP
  1609.                END
  1610.             END
  1611.             buffer=INSERT(replacement,DELSTR(buffer,position,taglength),position-1)
  1612.          END
  1613.       END
  1614.    END
  1615.  
  1616.    position =1
  1617.    taglength=0
  1618.    DO UNTIL position=0 | taglength<2
  1619.       position=POS('<',buffer,position)
  1620.       IF position>0 THEN DO
  1621.          taglength=POS('>',buffer,position+1)-position+1
  1622.          IF taglength>1 THEN DO
  1623.             taghead    =UPPER(WORD(SUBSTR(buffer,position+1,taglength-2),1))
  1624.             tagname    =COMPRESS(taghead,'/')
  1625.             replacement=''
  1626.             SELECT
  1627.                WHEN taghead='BR'     THEN replacement=lf
  1628.                WHEN taghead='A'      THEN replacement='{'
  1629.                WHEN taghead='/A'     THEN replacement='}'
  1630.                WHEN taghead='P'      THEN replacement=lf||lf
  1631.                WHEN taghead='/P'     THEN replacement=lf
  1632.                WHEN taghead='HR'     THEN replacement=lf'--------------------------------'lf
  1633.                WHEN taghead='IMG'    THEN DO
  1634.                   tag   =SUBSTR(buffer,position+1,taglength-2)
  1635.                   alt   =''
  1636.                   altpos=POS('ALT=',UPPER(tag))
  1637.                   IF altpos>0 THEN DO
  1638.                      altpos=altpos+4
  1639.                      PARSE VAR tag =altpos '"'alt1'"' =altpos "'"alt2"'"
  1640.                      alt=alt1||alt2
  1641.                   END
  1642.                   replacement='['alt']'
  1643.                END
  1644.                WHEN tagname='H1'|tagname='H2'|tagname='H3'|tagname='H4'|tagname='H5'|tagname='H6' THEN replacement=lf
  1645.                WHEN taghead='TH'|taghead='TD'|taghead='DT'|taghead='/DL'|taghead='/OL'|taghead='/UL' THEN replacement=lf||lf
  1646.                WHEN tagname='PRE'|tagname='DIV'|tagname='TABLE' THEN replacement=lf
  1647.                WHEN taghead='DD'     THEN replacement=' - '
  1648.                WHEN taghead='LI'     THEN replacement=lf||lf'* '
  1649.                WHEN taghead='TITLE'  THEN DO
  1650.                   titlelength=POS('</TITLE>',UPPER(buffer),position+taglength)-position-taglength
  1651.                   pagetitle  =SUBSTR(buffer,position+taglength,titlelength)
  1652.                   taglength  =taglength+titlelength+8
  1653.                END
  1654.                OTHERWISE NOP
  1655.             END
  1656.             IF replacement~='' THEN buffer=INSERT(replacement,DELSTR(buffer,position,taglength),position-1)
  1657.             ELSE buffer=DELSTR(buffer,position,taglength)
  1658.          END
  1659.          ELSE DO
  1660.             tagpart=SUBSTR(buffer,position)
  1661.             buffer =DELSTR(buffer,position)
  1662.          END
  1663.       END
  1664.    END
  1665. RETURN 0
  1666.