'set novalue on' /* force KEXX and its way of SIGNAL ON NOVALUE */ /* Usage: [MACRO] NETSCAPE [url|.|:] */ /* Example: NETSCAPE about:blank = show specified URL */ /* NETSCAPE = show this file:/// */ /* NETSCAPE . = show directory */ /* NETSCAPE : = show focusword.2() */ /* Option: define A-HOME 'macro NETSCAPE :' */ /* Purpose: Locate FOCUSWORD.2() or a specified argument as */ /* URL using configured brwowser NSC (see below). */ /* Character references in links aren't converted, */ /* but the known problem '&' is replaed by '&' */ /* See also: KHELP FOCUSWORD, KHELP REXX, RXLYNX.KEX */ /* */ /* */ /* Requires: Kedit 5.0 and a browser (modified for KeditW) */ /* (Frank Ellermann, 2008) */ NSC = 'd:\progra~1\mozill~1\firefox.exe' URL = arg( 1 ) ; rc = 0 if URL = ':' then URL = focusword.2() USE = translate( URL ) ; LOC = 'file://localhost/' if URL = '' & dir() = 0 then do URL = LOC || translate( fileid.1(), '/', '\' ) if alt() then 'save' ; if rc <> 0 then exit rc end else if URL = '' then URL = LOC || translate( dirfileid.1(), '/', '\' ) else if URL = '.' then URL = LOC || translate( directory.1(), '/', '\' ) else if abbrev( USE , '' /* (in text) */ else if abbrev( USE , '<' ) then parse var URL '<' URL '>' /* (in news) */ else if abbrev( USE , 'HREF="' ) then parse var URL =7 URL '"' /* href="any:url" (X)HTML */ else if abbrev( USE , 'HREF=' ) then parse var URL =6 URL '>' /* href=any:url> (in HTML) */ else if abbrev( USE , '"' ) then parse var URL '"' URL '"' /* "any:url" (strings) */ else if abbrev( USE , "'" ) then parse var URL "'" URL "'" /* 'any:url' (strings) */ else if sign( pos( '="HTTP://', USE )) then parse var URL '="' URL '"' /* any="http://url" (XML) */ else if abbrev( USE , 'HTTP://' ) then if verify( right( USE, 1 ), ':;,.', 'Match' ) then do URL = left( URL, length( URL ) - 1 ) end /* kludge for text URL with trailing comma or similar */ /* maybe add special handling of implicit file: and news: URLs */ /* maybe add special handling of explicit mailto:, dict:, etc. */ 'dosq cmd /c start' NSC QUOT( URL ) ; LOC = rc if rc <> 0 then 'emsg' NSC 'rc' rc ; 'msg href=' || QUOT( URL ) exit LOC /* 0: Kedit found cmd.exe */ QUOT: procedure /* quote URL using "...": */ parse arg SRC ; DST = '' ; POS = pos( '"' , SRC ) do while POS > 0 DST = DST || left( SRC, POS -1 ) || '%22' SRC = substr( SRC, POS +1 ) ; POS = pos( '"' , SRC ) end SRC = DST || SRC ; DST = '' ; POS = pos( ' ' , SRC ) do while POS > 0 DST = DST || left( SRC, POS -1 ) || '%20' SRC = substr( SRC, POS +1 ) ; POS = pos( ' ' , SRC ) end SRC = DST || SRC ; DST = '' ; POS = pos( ',' , SRC ) do while POS > 0 DST = DST || left( SRC, POS -1 ) || '%2C' SRC = substr( SRC, POS +1 ) ; POS = pos( ',' , SRC ) end SRC = DST || SRC ; DST = '' ; POS = pos( '&', SRC ) do while POS > 0 DST = DST || left( SRC, POS -1 ) || '&' SRC = substr( SRC, POS +5 ) ; POS = pos( '&', SRC ) end DST = '"' || DST || SRC || '"' ; return DST