Rainer Becker
dFPUG– Incorporated UG
– Portal.dfpug.de
German DevCon– Tenth time & price
Localization Toolkit– German, French, Czech (with Igor Vit)
Visual Extend MVP, MCP Wizards & Builders
Mixed Topics &Basic Directions
What are we talking about in general and in this session
Original Session description There are a lot of concepts in VFP that are different from
the official theory but help us with rapid application development. This session will show a set of examples when, where and why using VFP is a great advantage in software development, at least if you know what you are doing. Many of these subtitles might sound like contradictions in itself but maybe you can still use them in your day to day work, e.g. COM-servers made visible, database without integrity rules, VFP for Excel-users, read-only-access-methods, labels for checkboxes, segmented tables and other topics are presented in a fast paced tips & tricks fashion.
Session title might be misleading…
Topics Concepts of Visual
FoxPro in General Concepts of Visual
Extend in General Contradictive Example:
Visible COM-Servers Thumb databases are
more intelligent Configuration with
Dynamic Constants Main Work is user
interface – misc. Tipps
Concepts of Visual FoxPro and Visual Extend
Just to remind you of some basic stuff
Visual FoxPro Capabilities
Free unlimited application distribution Free unlimited database distribution Free unlimited reportwriter distribution
– Just add „MODI REPO ?“ to your menue
All in one tool (everything you need) Partially via integration (Help, Install) Fine-Tuned over a decade of development
• Lifecylce extended to 2014 with VFP 9
Visual FoxPro Language
Hybrid programming language– Procedural (great for batch jobs)
• Self-modifying code
– Data-aware commands• Compiled commands for local database engine
– Object-based (like Visual Basic)• But Using Containers instead of SimpleFrame
– Object-oriented (with Business Objects)• Ignoring theory of total encapsulation
Visual FoxPro Database
Hybrid database commands– Fast Xbase table commands (records)– SQL (groups, CURrent Set of recORds)– Mixed use (xbase on cursor), but my favorite
• Replace all a.val with b.val for seek( a.key, „b“)
„Compiled“ database access– Critic: no strict type checking in language– Vice versa: always database comand strings…
Visual FoxPro Special
OOP Special:– Awareness of parent and all other objects – Container subclassing incl. ActiveX-Controls– Ease of Redirection of subclassing– Not Collection-oriented only
PROG Special:– Evaluate, Macro, Excescript, Compile– Definition files are tables– Command window for direct execution
Visual Extend Capabilities
Proven framework with standard functions Rich set to enhance enduser application Builders for Rapid App. Development Standardized Design & Layout
– Standard forms for various tasks– Grid-Page for search, Edit-Pages for detail
Sourcecode included except Builders No Business Objects, just 2-Tier-Apps
Rapid Application Development
2 tiers are most often enough for a good and fast application of small to medium size
Customers often are not willing to pay much higher price for maybe lower maintenance cost in the future
Business functions can still be encapsulated in classes which are to be used by the GUI, but these do not have to be clean BOs
Rapid Application Conversion
If you do not try to re-invent the wheel conversion of FoxPro/Windows applications with the help of a framework is pretty fast-forward as you can take over tables, reports and batch-code
It is „kind of a re-write“ but not really as you can reuse your knowledge and rebuild the application very fast in VFP
Recommendation Software-architecture is
very interesting andthree-tiered appswith business objectsare very powerfull
But only if you can afford them or your client is willing to pay the way
Otherwise stick to RAD VFP / VFX is best suited for and build & sell apps
Visible COM-Servers
You were always told to use Business Objects in the middle tier with the advantage they can be re-used via COM
Main object
COM-Server need one OLE-Public object– this does not have to be a business object
• Most often BO are not best choice to be accessed directly from outside of the application!
– It has to be an object• a wrapper for a BO is needed at least
Based on control or container– Called via createobject from other apps– Methods/properties are accessable so they have
to be protected …
Access/Assign and Parameters
Protect Methods / Properties– Small Interface: Hide Properties / Methods– Extensive parameter checking in Methods– Add Assign-Methods to Properties
Assign- & Access-Methods– Vartype and allowed values (list, valid date)– Formatting (Uppercase, remove spaces)– Read-only properties– Internal access only (hidden property switch)
Additional Preparation
Check startmodeINLIST( _vfp.startmode, 2,3,5 )
disable automation server unattended mode=SYS(2335,1)
Integrate error handling=COMRETURNERROR
• Should also be called from access/assign-methods
Set all your settings – Reminder: Press Strg+OK in Options dialog
Project Definition
Add a main program just to have it– Your test program is a good main program
Include Metadata-tables in project Include Config.fpw in project
– SCREEN = OFF (invisible VFP desktop)– RESOURCE=OFF (prevent foxuser creation)– ALLOWEXTERNAL=ON (additional config)
Make visible when needed
Application Execution
Example in Excel:– Dim loRef as Object– On Error Goto SomeError– Set loRef = createobject(„exe.obj“)– … other operations– Set loRef = Nothing
Excel developers love VFP-data-access as it is much easier for them then ODBC/ADO!
Application Rollout
Runtime Directory contains– <Yourserver>.exe– VFP8R.DLL, VFP8RENU.DLL– GDIPLUS.DLL– REGSVR32.EXE
MSVCR70.DLL to system32 Regsvr32.exe vfp8r.dll <Yourserver>.exe /regserver
Recommendation We use WinWord, Excel,
Outlook, Internet Explorer and other applications by calling them…
Why dont we provide the same VISIBLE function-ality to our customers?
Especially Excel-/Word developers are interested!=> additional market…
Intelligent Databases are a problem for programmers
Why make your live even more complicated ?
Reasons for a dumb datastore
Switching backends is a nightmare if validations are additionaly stored in the database (including key generation/RI)
Temporary saving of invalid records is helpfull for a lot of users (lActive/lValid)
Synchronization is a disaster if records can only be added with correct parent/child-relations set
Recommendation If you want to use
different backends:– No valids, RI, triggers
– No DBCX
– Handle logic in apps
A lot of developers have good experience in practise with dumb datastores for switching and synchronisation …
Dynamic Constants
Repetition how to use constants and additional ways to use Constants for later application configuration
Constants Basics
#DEFINE CONSTANT Value– Not working within „“ or ‚‘
• compared to &, example ?„W&B“ with m.b defined
– But working within [ ]
#UNDEFINE CONSTANT Only in program or current method Use #INCLUDE or Class/Form dialog
– Multiple levels of inclusion possible
Conditional Constants
#IF condition (constant or VFP function)– #ELSE, #ELIF cond, #ENDIF
#IFDEF, #IFNDEF constant– #ELSE, #ENDIF
Some examples– #INCLUDE Foxpro.h / Messagebox-example– #IF .F. for comments– Do not use DEFINE … #IF .F. (optimized)
• Except for temporary exclusion of complete class
More exciting use for constants Array dimensions and column names
– laTemp( lnCounter, CONST_COL_NAME) Translation of strings
– lcMessage = CONT_MSG_TEXT Replacement of commands
– LOCATE FOR CONT_LOC_COND Version dependent functionality
– Both for VFP as well as own version Comment out SUSPEND, DEBUG …
– #DEFINE SUSPEND *, DEBUG * Not working any more: Commentblock
– See above, #DEFINE BeginComment #IF .F. not working
Real world examples
Example 1 / Profiler:Constants for Tablenames, Boundaries, Captions,
Colors, Classes, Combined Messages
Example 2 / VFXSync: Constants for Steps / Messages, Metatablenames,
Metafieldnames, Parameter lists, locate statements, logfilenames, aliases
In-Between-Code
Place constants before and after calls #DEFINE BEFORE/AFTER/WITHIN * #INCLUDE useroverwrite.h Use running status-variable
– For IF/ENDIF-blocks – To change running var within code
No need for calls to emtpy methods Longer compilation time but faster runtime
Recommendation You can increase the
configurability of your sourcecode with constants
Only in case you really need to configure you change the header-file.
No performance penalty compared to table-driven or any other way to configure your apps
Main work is stillthe user-interface
Most time is still spend of user interface design and validations
GUI-functions encapsulation
Very powerfull Textmerge()-function can be used in a variety of ways– Addressformatter
– Addressabreviator (not IntelliSense)
Build in button-click and when done save as class for reuse on other forms
You do not have to go multi-tier, but still it is an advantage to use classes and subclassing – if you separate out user interaction (spagetthi-code!)
Source example TextMerge() Format-Memofield contains various <<alias.fieldname>> in correct
position plus hardcoded addtional information like country short code
SELECT adressformatLOCATE FOR adressformat.country = lcCountry ;
AND adressformat.active = .T.IF FOUND()
lcFormat = adressformat.formatlcFormat = TEXTMERGE( lcFormat )IF NOT EMPTY( lcFormat )
lcMessage = "adress copied to clipboard"_CLIPTEXT = lcFormat
ENDIF ENDIF
Recommendation Important is not to
clutter code all over your forms but to place them in a central place, might it be buttons in a classlib or a business object
Important is to allow for GUI-mode and just a function call with return value
Famous last words
Use Visual FoxPro in the right way – for you and your applications
More and more functionality
Fast development experience
With VFP alone as well as with additional tools and frameworks
Best tool for fast development
.NET is stillnot „ready“
PHP / mySQLno option
VFP will be extended even further
Good option for now as 4 GL
Thank You! Please do not forget the
evaluation form!
Visit our websiteswww.dfpug.de
portal.dfpug.de
forum.dfpug.de
wiki.dfpug.de
www.visualextend.de
www.visualfoxpro.de
www.wizards-builders.com
Top Related