Imported Visual FoxPro Files

From Lianjapedia
Jump to: navigation, search

See Also

Accordion Behavior, Building Lianja Mobile business database Apps, Command Line Switches, Data workspace, File Extensions, Importing Visual FoxPro Databases and Tables, Importing Visual FoxPro Files, Lianja Cloud Server: Server side procedures, Lianja SQL Server, JavaScript built-in Lianja/VFP functions, NoSQL commands, SQL commands, Visual FoxPro Server Pages (.rsp)

Overview

This article explains how imported Visual FoxPro databases, tables, programs, forms and class libraries can be used in your Lianja Apps.

For information on how to import Visual FoxPro files, see:

Note: the import functionality is available on Windows only. Once imported, the files can also be used in Lianja on Mac and Linux.

For an introduction to building Lianja Apps, see Getting Started.

The examples here use the Visual FoxPro Recipes database and project.

Databases and Tables

After importing Visual FoxPro databases and tables, the new files will be located in a sub-directory of lianja\data\ with the same name as the database.

Imported recipes database


Click here for file extension descriptions.

The imported database and tables are in Lianja native format, so can be viewed and modified in the Data workspace, bound to controls in Apps and used with commands, functions and SQL statements.

For a closer look at the new database and tables, open them in the Data workspace or from the Lianja/VFP command window (Console workspace, system menu or App Inspector):

open database recipes
list database

Note that when Lianja imports Visual FoxPro tables, it also recreates production .cdx index tags in a .dbx file. To view just the indexes for a particular table, use the list indexes command.

use recingrd
list indexes

If specific index tags are no longer required for use in Lianja, they can be deleted using the delete tag command. To remove all tags, use the nodbx keyword on the use command:

use recingrd nodbx

Since the database and tables are in Lianja native format, they cannot be opened directly from Visual FoxPro. The NoSQL copy to command and the SQL select statement can be used to save Lianja data in a variety of export formats. Alternatively, the Lianja ODBC Driver allows access to Lianja data via the Lianja SQL Server.

Programs, Forms and Class Libraries

Importing Visual FoxPro project files (.pjx files) creates source code versions of the project's forms (.scx converted to .scp) and class libraries (.vcx converted to .vcp) in the Lianja App. Program (.prg) and text files (.txt) are also added to the Lianja App and keep their file extensions.

For desktop Apps, there are three ways of using the imported source code:

  • Run programs (.prg) and forms (.scp) directly, referencing class libraries (.vcp)
  • Embed forms as Lianja Custom Sections within Lianja Pages
  • Rebuild the UI using Lianja Standard Sections, reusing business logic source code in event delegates and other called procedures and functions. This is the recommended method.

For web/mobile Apps, imported source code can be reused in server side procedures and Visual FoxPro Server Pages (.rsp). The UI must use Lianja Standard Sections and JavaScript client side code. Note that the Lianja web/mobile client supports JavaScript built-in Lianja/VFP functions to aid conversion of Visual FoxPro code to JavaScript.

Desktop Apps

As mentioned above, the recommended method of handling imported source code is to reuse non-UI code in Lianja/VFP event delegates and other called procedures and functions while rebuilding the UI in the Lianja visual Page Builder with Lianja Standard Sections.

Before embedding forms in Lianja Pages it is recommended to test them using Direct Calling and make any required modifications first.

For Apps to be run on the desktop and in the web/mobile client, see the section on Web/Mobile Apps below.

Direct Calling

Lianja supports the do form and do commands to call forms (.scp) and programs (.prg) respectively.

Using the Lianja/VFP command window in the Console workspace allows the output and error windows to be monitored. Error are also reported in the lianja\debug\debug_xxx.txt file (where xxx is the process id) with additional information. Modifications should be made to the .scp or .prg source code.

Do form



Here the unsupported Relation class used in recipes.scp is reported in the Console workspace error window and the debug file. After modifying recipes.scp to open the database, tables and set up the relations using NoSQL code, recipes.scp is rerun using do form.


Edit .scp file



Here the recipes.scp has been edited in the Script Editor in the Apps workspace.


During the import, .scp files automatically have set classlib commands added to open referenced class libraries. To add any additional class libraries (.vcp), edit the .scp file adding the set classlib command. The 'additive' keyword should be used so that previously loaded class libraries are not closed.

Once your forms are running, you can proceed to embed them as Lianja Custom Sections or they can be deployed called from a program. The program must be a .dbo file, which is a compiled .prg file. Program files are compiled automatically when run in the Lianja App Builder development environment, or can be compiled using the compile command. For information on calling a program in the Lianja App Center desktop runtime client, see Command Line Switches, particularly the Filename section.


Embedding in Lianja Pages

New Page based on imported .scp form file



After importing Visual FoxPro forms into an App, they are available from the Page menu in the Form Tools in the Page Builder.

Just select the .scp file and a new Page will be created with a single full page Custom Section based on the form code.


Page based on imported .scp form file



The PageFrame is on a single Lianja Page.


New Page based on imported .scp form file



Add a new Page for each of the forms you want to include in the App.


New Page based on imported .scp form file



Note that the Custom scripting code 'Custom UI library' and 'Custom UI class' have been populated for the Custom Section.


Creating init procedure to open data



Here the code to open the database and tables and set up the relations has been moved from the recipes.scp file into the App init delegate so that it is called when the App is opened. App delegates can be specified in 'Settings' (bottom of the modebar).


Using Lianja Standard Sections

In desktop Apps, imported source code can be combined with a UI based on Lianja Standard Sections (Forms, Grids, Canvas Sections etc.). This gives you the best of both worlds. You can still reuse your non-UI code in Lianja/VFP event delegates and called procedures and functions, but benefit from data-bound sections with built in navigation and action buttons created using visual drag and drop design.

App using standard sections



Here the UI has been rebuilt using Form, Grid and TabView sections.


Web/Mobile Apps

Settings



Make sure the App Settings 'Scripting language' is set to JavaScript and the 'UI Presentation Rules' has 'Web' checked.


TabView Section



Here's a web App using using Form, Grid and TabView sections.

The 'Recipe List' is created by a simple .rsp Server Page and displayed when the 'List Recipes' menu option is clicked.

(See customerlist.rsp in the example_mobileapp1 demo App in the distribution for how this is done.)


Stacked Accordion



Here is an alternative layout using a Stacked Accordion.


Mobile App with Accordion Behavior Page



Accordion Behavior is ideal for mobile Apps.


Mobile App with Accordion Behavior Page



As a section is selected, the other sections are collapsed, making the most of the available screen space.


Using a .rsp dialog



The 'Recipe List' .rsp based dialog is also given full screen space when opened.