Presentation is loading. Please wait.

Presentation is loading. Please wait.

Tips and Tricks for Microsoft Visual FoxPro German FoxPro User Group Rainer Becker Frankfurt/Germany TRICKS.

Similar presentations


Presentation on theme: "Tips and Tricks for Microsoft Visual FoxPro German FoxPro User Group Rainer Becker Frankfurt/Germany TRICKS."— Presentation transcript:

1 Tips and Tricks for Microsoft Visual FoxPro German FoxPro User Group Rainer Becker Frankfurt/Germany TRICKS

2 Rainer Becker dFPUG –Online offers –Loose Leaf magazine VFP-DevCon Localisation Framework Visual Extend MVP, MCP Wizards & Builders GmbH

3 Session Topics Visible COM-Servers Dynamic Constants User Interface Dumb Databases

4 Visible COM-Servers Business Objects can be turned into COM-Servers to process business logic in unattended mode – but you can create visible COM-servers to…

5 Main object COM-Server need a OLE-Public main object –It does not have to be a business object Very often real business objects are not suited to be called from outside / other applications (especially via Internet) –But it has to be an object At least a Wrapper-Object is needed Based on controls or container class –Called via „createobject“ from other applications –Methods/Properties are visible/changeable –Therefore need to be „protected“

6 Access and Assign Methods Protected Methods / Properties –Small interface: Hiding Methods / Properites –Extensive parameterchecking in methods –Access/Assing-methods for properties Assign- & Access-Methods –Vartype and valid values (value list, date range, …) –formatting (upper case, spaces, …) –Write-protect properties –Internal properties (hidden property switch)

7 Additional preparation Check startmode INLIST( _vfp.startmode, 2,3,5 ) Disable Automation Server Unattended Mode =SYS(2335,1) Integrate error handling =COMRETURNERROR Also from/within Access/Assign-Methods Set all your settings –Old trick: Strg+OK lists all options…

8 Project definition Add main program… –E.g. use test program for that Include metadata tables Include Config.fpw –SCREEN = OFF (invisible VFP desktop) –RESOURCE=OFF (prevent foxuser creation) –ALLOWEXTERNAL=ON (additional config) Turn visible on if/when necessary

9 Application Execution Example in Excel: –Dim loRef as Object –On Error Goto SomeError –Set loRef = createobject(„exe.obj“) –… other operations –Set loRef = Nothing Excel-developer love VFP-based data access, as it is much easier than ODBC/ADO for them! –No redefinition of all SQLs if field added/removed –Problems with transfer of memofields

10 Application Rollout Runtime subdirectory contains –.exe –VFP9R.DLL, VFP9RENU.DLL –GDIPLUS.DLL –REGSVR32.EXE MSVCR70.DLL in system32 Regsvr32.exe vfp9r.dll.exe /regserver

11 Summary COM-Server We use WinWord, Excel, Outlook, Internet Explorer and other applications by calling them Why dont we offer the same VISIBLE functionality our customers? Especially Excel-/Word- developer/user are an additional market…

12 Dynamic Constants Constants are constantly used to seldom - and should be more dynamic anyhow. Underestimated power…

13 Base knowledge #DEFINE CONSTANT Value –Does not work within „“ or ‚‘ Different from &, e.g. ?„W&B“ with m.b = value –But does work with brackets! [Beware] #UNDEFINE CONSTANT In programs or current method #INCLUDE or Class/Form Dialog –Recursive calls possible

14 Conditional constants #IF Condition (constant or integrated VFP function at compile/design time) –#ELSE, #ELIF condition, #ENDIF #IFDEF, #IFNDEF constant –#ELSE, #ENDIF Example –#INCLUDE Foxpro.h / Messagebox –#IF.F. for comments –DEFINE … #IF.F. does not work (optimized) Except for temporarily disable complete classes

15 Additional use Array dimensions and row / column names –laTemp( lnCounter, CONST_COL_NAME) Translation of strings for localization –lcMessage = CONT_MSG_TEXT Replacement of commands, command lines or conditions –LOCATE FOR CONT_LOC_COND Version dependant functionality –for VFP-version or own program versions Commenting out of SUSPEND, DEBUG … –#DEFINE SUSPEND *, DEBUG * Does not work no more: Commentblock –See above, #DEFINE BeginComment #IF.F. does not work

16 Real world examples Example 1 / Profiler: constants for tablenames, value ranges, captions, colors, classes, assembled multi-part messages Example 2 / VFXSync: Contants for steps /messages, meta table names, meta table field names, parameter lists, Locate-commands, logfilenames, table alias

17 In-Between-Code Contants before and after function calls #DEFINE BEFORE/AFTER/WITHIN * #INCLUDE useroverwrite.h Variables for application status –For IF/ENDIF-sections –To change statusvar within code Advantage: No calls to empty methods More compile-time but faster run-time

18 Summary Constants Configurability drastically enhanced by using constants Only if you really want to change application you change the headerfiles No Performance-Penalty compared to all other ways of configuring application for special needs

19 User Interface Majority of programming time is used for user interface design and user interface logic (validations, refresh)

20 Encapsulation of functions Very often a special business object is to complex and by far to much overhead Save functionality in additional button method and call it via button click Save button as class and replace button control with class for later reuse in other places You do not really have to have multi-tiered architecture – but classes do have big advantages, especially to separate complex interactions from form code

21 Example Addressformater-button Powerfull Textmerge()-function can be used in multiple ways: –Addressformatter –Addressabreviator (not IntelliSense) –Scripting –End user makros –Mail merge

22 Example Textmerge Format-Memofield contains various > 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

23 Summary User Interface Do not scatter your code all over your application At least place special functionality in classes It does not have to be a business object

24 Dumb Databases Intelligent database are a problem sometimes. Why should be make our programmer lives even more complicated…

25 Reasons for stupid databases Switching to backend-database is a nightmare if validations are saved within the database Temporarily saving of records is impossible –Even backups of records have to comply to all rules Different record types in the same table makes validation rules by far to complex Rules of user interface and business logic duplicated in database results in much higher maintenance costs –Multiplied by number of backends supported

26 Synchronization Synchronization is only possible in the correct order of parent/child-relations Synchronization only possible between data- bases with same structure … and same level of validation code Synchronization example code has been shown throughout the session Will be available as integrated or separate module for our framework Visual Extend

27 Summary Databases Place only base logic within the database and no complex validations Application logic should stay in the application Many developers found that it eases their daily work if the database is not to intelligent! Or use tools like XCASE to generate database rules

28 Thank You! Visit our websites at http://www.dfpug.de, http://portal.dfpug.de, http://forum.dfpug.de, http://newsletter.dfpug.de, http://devcon.dfpug.de, http://roadshow.dfpug.de, http://www.visualextend.com, http://www.linuxtransfer.de, http://www.visualfoxpro.dehttp://www.dfpug.de http://portal.dfpug.dehttp://forum.dfpug.de http://newsletter.dfpug.dehttp://devcon.dfpug.de http://roadshow.dfpug.dehttp://www.visualextend.com http://www.linuxtransfer.dehttp://www.visualfoxpro.de


Download ppt "Tips and Tricks for Microsoft Visual FoxPro German FoxPro User Group Rainer Becker Frankfurt/Germany TRICKS."

Similar presentations


Ads by Google