Imported Visual FoxPro Files
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.
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
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.
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.
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.
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.
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
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.
The PageFrame is on a single Lianja Page.
Add a new Page for each of the forms you want to include in the App.
Note that the Custom scripting code 'Custom UI library' and 'Custom UI class' have been populated for the Custom Section.
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.
Here the UI has been rebuilt using Form, Grid and TabView sections.
- Lianja/VFP programs can be run as server side procedures.
- Imported Visual FoxPro code can also be reused in Visual FoxPro Server Pages (.rsp).
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.)
Here is an alternative layout using a Stacked Accordion.
Accordion Behavior is ideal for mobile Apps.
As a section is selected, the other sections are collapsed, making the most of the available screen space.
The 'Recipe List' .rsp based dialog is also given full screen space when opened.