Title: SEM03 Having Fun with VFP (some samples from VFX)
1SEM03Having Fun with VFP(some samples from VFX)
- Rainer Becker
- Rainer.Becker_at_dFPUG.de
2Rainer 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
3Mixed Topics Basic Directions
- What are we talking about in general and in this
session
4Original 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
5Topics
- 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
6Concepts of Visual FoxPro and Visual Extend
- Just to remind you of some basic stuff
7Visual 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
8Visual 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
9Visual 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
10Visual 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
11Visual 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
12Rapid 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
13Rapid 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
14Recommendation
- 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
15Visible COM-Servers
- You were always told to use Business Objects in
the middle tier with the advantage they can be
re-used via COM
16Main 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
17Access/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)
18Additional Preparation
- Check startmode
- INLIST( _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 StrgOK in Options dialog
19Project 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)
- RESOURCEOFF (prevent foxuser creation)
- ALLOWEXTERNALON (additional config)
- Make visible when needed
20Application 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!
21Application Rollout
- Runtime Directory contains
- ltYourservergt.exe
- VFP8R.DLL, VFP8RENU.DLL
- GDIPLUS.DLL
- REGSVR32.EXE
- MSVCR70.DLL to system32
- Regsvr32.exe vfp8r.dll
- ltYourservergt.exe /regserver
22Recommendation
- 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!gt additional market
23Intelligent Databases are a problem for
programmers
- Why make your live even more complicated ?
24Reasons 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
25Recommendation
- 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
26Dynamic Constants
- Repetition how to use constants and additional
ways to use Constants for later application
configuration
27Constants Basics
- DEFINE CONSTANT Value
- Not working within or
- compared to , example ?WB 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
28Conditional 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
29More 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
30Real 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
31 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
32Recommendation
- 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
33Main work is stillthe user-interface
- Most time is still spend of user interface design
and validations
34GUI-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!)
35Source example TextMerge()
- Format-Memofield contains various
ltltalias.fieldnamegtgt in correct position plus
hardcoded addtional information like country
short code - SELECT adressformat
- LOCATE FOR adressformat.country lcCountry
- AND adressformat.active .T.
- IF FOUND()
- lcFormat adressformat.format
- lcFormat TEXTMERGE( lcFormat )
- IF NOT EMPTY( lcFormat )
- lcMessage "adress copied to clipboard"
- _CLIPTEXT lcFormat
- ENDIF
- ENDIF
36Recommendation
- 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
37Famous last words
- Use Visual FoxPro in the right way for you and
your applications
38More and more functionality
39Fast development experience
- With VFP alone as well as with additional tools
and frameworks
40Best tool for fast development
- .NET is stillnot ready
- PHP / mySQLno option
- VFP will be extended even further
- Good option for now as 4 GL
41Thank You!
- Please do not forget the evaluation form!
- Visit our websites
- www.dfpug.de
- portal.dfpug.de
- forum.dfpug.de
- wiki.dfpug.de
- www.visualextend.de
- www.visualfoxpro.de
- www.wizards-builders.com