Wiki Home

Insta Link


Namespace: DotNet
* program to make a href link out of a url
* the text of the link is the url, less the "http://"
* the url is taken from the clipboard
* the result is placed on the clipboard

* #DEFINE FOXWIKIBASE "http://www.fox.wikis.com/wc.dll?wiki~"
#DEFINE FOXWIKIBASE "http://fox.wikis.com/wc.dll?wiki~"

#DEFINE MSKBBASE "http://support.microsoft.com/support/kb/articles/"
#DEFINE HACKFOXBASE "mk:@MSITStore:C:\Program%20Files\Microsoft%20Visual%20Studio\Vfp98\"

local ;
	lcUrl, ;
	lcTxt, ;
	lcLnk

lcUrl = _cliptext
lcTxt = lcUrl

* fix?
if !inlist( upper( lcUrl ), "HTTP://", "MK:" )
	lcUrl = "http://" + lcUrl
endif

* refine text of simple (ip name only) addresses
if upper( lcTxt ) = "HTTP://" ;
	and inlist( right( upper( lcTxt ), 4 ), ".COM", ".ORG.", ".NET" )
  lcTxt = substr( lcTxt, 8 )
endif

* refine FoxWiki pages
if lower( lcTxt ) = FOXWIKIBASE
	lcUrl = strtran( lcUrl, "Update~" )
	lcTxt = strtran( lcUrl, FOXWIKIBASE )
	lcTxt = strtran( lcTxt, "~VFP" )
endif

* refine text of MS KB pages - start with address, construct the Qxxxx text
if lower( lcTxt ) = MSKBBASE
	lcTxt = strtran( lcTxt, MSKBBASE )
	lcTxt = strtran( lcTxt, "/" )	
	lcTxt = strtran( upper( lcTxt ), ".ASP" )
endif

* Hackers Guide pages
if ( lcTxt ) = HACKFOXBASE
	lcTxt = strtran( lcTxt, HACKFOXBASE )
	lcTxt = strtran( lcTxt, ".HTML" )
endif

* Construct an address out of a Qxxxx MS KB id
if upper( substr( lcUrl, 1, 1 ) ) = "Q" and !empty( val( substr( lcUrl, 2 )) )
	lcUrl = MSKBBASE + transform( lcTxt, "@R XXXX/X/XXXX" ) + ".asp cHECK ME!"
endif

* 
lcLnk = '< a href="' + lcUrl + '">' + lcTxt + '< /a>'

? lcLnk

_cliptext = lcLnk



contributors -- Carl Karsten
warning: editing this page screws up the HTML tags
this needs an impovement: strip the ~namespace from wiki links.
Category Code Samples
( Topic last updated: 2000.09.18 11:36:30 AM )