Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Detecting field presence in dbf
Message
From
31/07/2007 02:40:02
 
 
To
29/07/2007 13:01:21
Mike Yearwood
Toronto, Ontario, Canada
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01244177
Message ID:
01244773
Views:
29
Hi Mike,
>>#define IsThereAFieldCalled !SPace(0)==Field
>>*-- Space may be a tad slower than "" or '',
>>*-- but removing the string marker makes it less brittle

>Very cool. I've used that before and it is very fast. It's just not as flexible as I'd like. You had to pre-code the formula in such a way as to make the ("somefield","somealias") the last part. My SnippetFactory lets me inject any number of "parameters" anywhere in a forumla or snippet with the result being evaluated.

I am pretty sure we agree quite a bit on "what is suboptimal in code" - as you see from the comment I even take a small perf hit to regain part of the flexibility - but that our personal habits make certain "code deficits" less odious and "accepted seeing the consequences".

The SnippetFactory I already have used (in a slightly altered version) for building SQL-statements.
Main changes: Added optional default values in the snippet-table, so "mostly stable" settings don't need that much code
Changed parameter object class into empty object, mangled internal name a bit heavier and moved the GetName-Method to the factory
(since it is used only once, the method could be eliminated and the mangled property used directly - style discussion imminent<g>).

The personally most annoying thing was that SQL with inline commentary was currently not working - for me the base "flaw" in Text..EndText. This is/was also *for me* the reason not to use "Text To" as much as others do in creating SQL statements. "My" style is
  select ;
  	m.lcFullName as fullname ;		&& Line in pure Text
  	from TestSnippet ;			&& Table we have open
  	into cursor c_Test readwrite
or 
  lcSQL =   "select";
  	+ " m.lcFullName as fullname" ;		&& Line in pure Text
  	+ " from TestSnippet" ;			&& Table we have open
  	+ " into cursor c_Test readwrite"
so for Snippetfactory I needed a better cleanline function, as
text TO lcSQL TEXTMERGE NOSHOW
  select ;
  	m.lcFullName as fullname ;		&& Line in pure Text
  	from TestSnippet ;			&& Table we have open
  	into cursor c_Test readwrite
ENDTEXT
&lcSQL
will fail miserably. So now i have a more elaborate CleanSQL... Wanted to send it to you but something always came up. Will look for it today at work and port it back into the base example.

Coming back to "personal style": While I use different patterns of dynamic code from class/method factory approaches over the snippet factory up to a table based rule engine generating whole elaborate functions I will keep trying to formulate fast checks via pre-processor - as this IMHO speeds up reading code (as neccessary for maintainance) und *for me* eliminates some "stupid blunders"/typo's. And I'ld always tryx to refrain from afields()-based approaches, as this ***can*** put a real damper on the speed of the check which makes that approach unusable as basic abstraction.

regards

thomas
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform