Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ETecnologia could define vfp10
Message
De
23/03/2007 03:58:55
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01205398
Message ID:
01207526
Vues:
23
Hi Samuel,

as you mentioned, you prefer vfp code instead of .Net-implementations.
This will give you some independance against breaking changes in the fwk at the cost of slightly more code (and perhaps some runtime penalties - new territory on perf for me <g>).

During lunch break yesterday I spruced up a few routines from an old FPW-support project,
which should be fitting as they are pure vfp code... They are *very* simple but raise the No. of functions a bit. The new routines I just named after the vfp-routine with an "_E" added and used normal vfp variable naming conventions to be able to compare the results. I hope I thought of all the fringe cases - adding to the unit test is very simple: Just add a call to Justline with the text to check against as first parameter. At least the mayor branches should be covered: in the original version there was a bug nobody ever encountered (and it makes no sense in OS-usage).

IN the code you sent you use the newer .Net "no hungarian" notation - if you offer some guidelines, I can adhere there as well.

Over the weekend I will begin a unit test for alines() [fringe cases involving the order of multiple multi-char-separators need to be covered], create a virtual machine and install your extender.

Do you have a special mailadress for such cases, as I am not sure this is the right place to exchange offerings to your compiler ?

regards

thomas

IAC, a few lines
clea
= JustLine("Hallo\Pa\Nex\men.34", "DOS Separators")
= JustLine("Hallo/Pa/Nex/men.34", "DOS Separators")
= JustLine("Hallo/Pa\Nex/men.34", "DOS and Unix Separators")
= JustLine("Hallo/Pa\.\\..//../Nex/men.34", "Dots, DOS and Unix Separators")
= JustLine("Hallo/Pa\Nex/men.34/", "Trailing Unix Separator")
= JustLine("Hallo/Pa\Nex/men.34\", "Trailing DOS Separator")
= JustLine("Hallo/Pa\Nex/me:n.34", ": put into Stem")
= JustLine("Hallo/Pa\Nex/me:n.3:4", ": put into Stem and Ext")
= JustLine("C://Hallo/Pa\Nex/me:n.3:4", ": put into Stem and Ext")
= JustLine("C:\Hallo/Pa\Nex/me:n.3:4", "JustDrive Test and : put into Stem and Ext")
= JustLine("C:me:n.3:4", "No Slash: Path NOT filled")
= JustLine(":me:n.3:4", "Drive and Path NOT filled")
= JustLine("::me:n.3:4", "Drive filled and Path NOT filled")
= JustLine("/:me:n.3:4", "Drive filled and Path NOT filled")
= JustLine("\:me:n.3:4", "Drive filled and Path NOT filled")
= JustLine(":\me:n.3:4", "Drive not filled and Path NOT filled")
= JustLine(":\me:n.3:4.", "Drive not filled and Path NOT filled")
= JustLine("Hydra://Hallo/Pa\Nex/me:n.3:4", ": put into Stem and Ext")


function JustLine(tcTest, tcComment)
	do case
		case !addbs(m.tcTest)		== AddBs_E(m.tcTest)
			= JustShowAll(m.tcTest, "Failed AddBs " + m.tcComment)
			? AddBs_E(m.tcTest)
		case !justdrive(m.tcTest)	== JustDrive_E(m.tcTest)
			= JustShowAll(m.tcTest, "Failed JustDrive " + m.tcComment)
			? JustDrive_E(m.tcTest)
		case !justpath(m.tcTest)	== JustPath_E(m.tcTest)
			= JustShowAll(m.tcTest, "Failed JustPath  " + m.tcComment)
			? JustPath_E(m.tcTest)
		case !justfname(m.tcTest)	== JustFName_E(m.tcTest)
			set step on
			= JustShowAll(m.tcTest, "Failed JustFName " + m.tcComment)
			? JustFName_E(m.tcTest)
		case !juststem(m.tcTest)	== JustStem_E(m.tcTest)
			= JustShowAll(m.tcTest, "Failed JustStem  " + m.tcComment)
			? JustStem_E(m.tcTest)
		case !justext(m.tcTest)		== JustExt_E(m.tcTest)
			= JustShowAll(m.tcTest, "Failed JustExt   " + m.tcComment)
			? JustExt_E(m.tcTest)
		otherwise
			? "Ok" , m.tcComment
			* = JustShowAll(m.tcTest, "ok " + m.tcComment)
	endcase

function JustShowAll(tcTest, tcComment)
	?
	? tcTest
	? tcComment
	? "Drive:", justdrive(m.tcTest)
	? "PAth :", justpath(m.tcTest)
	? "FNAme:", justfname(m.tcTest)
	? "Stem :", juststem(m.tcTest)
	? "Ext  :", justext(m.tcTest)

function AddBs_E(tcString)
	return iif(right(m.tcString,1)=="\", m.tcString, m.tcString+"\")

function JustDrive_E(tcString)
	return iif (substr(m.tcString,2,1)==":", left(m.tcString, 2), "")

function JustPath_E(tcString)
	local lnLAstSlash
	lnLAstSlash = max(rat("/",m.tcString), rat("\",m.tcString))
	return icase(	m.lnLAstSlash=0, "";
		,	m.lnLAstSlash=1, left(m.tcString, 1);
		,	left(m.tcString, lnLAstSlash-1))

function JustFName_E(tcString)
	local lnDivider
	lnDivider = max(rat("/",m.tcString), rat("\",m.tcString))
	do case
		case m.lnDivider=1
			RETURN JustFName_E_DoubDot(m.tcString)
		case m.lnDivider>1
			return substr(m.tcString,m.lnDivider+1)
		otherwise
			RETURN JustFName_E_DoubDot(m.tcString)
	endcase

function JustFName_E_DoubDot(tcString)
		if substr(m.tcString, 2, 1) ==":"
			if len(m.tcString)>2
				RETURN substr(m.tcString, 3)
			else
				return ""
			endif
		else
			return m.tcString
		endif

function JustStem_E(tcString)
	local lcFNAme, lnLastDot
	lcFNAme = JustFName_E(m.tcString)
	lnLastDot = rat(".", m.lcFNAme)
	return iif(m.lnLastDot=0, m.lcFNAme, left(m.lcFNAme, m.lnLastDot-1))

function JustExt_E(tcString)
	local lcFNAme, lnLastDot
	lcFNAme = JustFName_E(m.tcString)
	lnLastDot = rat(".", m.lcFNAme)
	return iif(m.lnLastDot=0 or m.lnLastDot=len(m.lcFNAme), "", subst(m.lcFNAme, m.lnLastDot+1))
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform