Results 1 to 6 of 6

Thread: [Answers] VFP migration

Hybrid View

  1. #1
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135

    [Answers] VFP migration

    For testing purposes you can select the Console Workspace and enter DO <program>, or DO FORM <.scp_file_name>.
    Unfortunately you can not visually manipulate your existing VFP forms if that's what you are trying to do.



    Drag/drop your VFP data files into Lianja and they will be converted automatically



    You only need to specify the extension if it is not the default extension. So for DO the default extension is '.prg', for DO FORM, the default extension is '.scp'. Similarly, for SET CLASSLIB, the default extension is '.vcp'.



    Q:
    Everything seemed to work on the imports, but what do I do to make it run?
    A:
    Imports of Visual FoxPro projects, classes and forms extract the data from the VFP tables and generate source code scripts in your App. Start from the Lianja/VFP Command Window in the Console Workspace and run your scripts using DO or DO FORM and issue any required SET CLASSLIB or SET PROCEDURE commands to reference libraries.
    Check the Error and Log windows in the Console Workspace for any issues. Your scripts can be edited in the Apps Workspace.
    Form scripts (*.scp) can also be referenced from a Page (Pages Workspace -> Form Tools -> Page), in which case they are embedded in a full-Page sized VFP Custom Section in your App. To modify the Custom Section, edit the Form script on which it is based, to add other Pages to the App, use any of the wide range of Lianja in-built Sections.



    Q:
    I'm imported the entire project. And now what follow?
    A:
    After importing, these are the steps:
    1. Test your forms/programs from the Lianja/VFP Command Window in the Console or in the App Inspector using DO FORM or DO and check the Error Window/Tab for any errors reported.
    2. If you want to embed your forms into Lianja Pages, select them from the Form Tools -> Page list of imported forms.
    3. Complete your App with any additional or replacement Pages.
    4. Set the Published checkbox in your App Settings.
    5. In the Deploy Worksurface, create an Installer exe for your App, Data and any Library scripts. Include the Lianja App Center (download the distribution and copy into the lianja\redist folder) if required. The 'template' installer can be used as a model for your own installer.



    When the importer reads your scx files, it will pick up the classloc for the objects and add in a
    set classlib to "name-of-classlib" additive

    at the top of the scp source files it creates (your vcx files will be imported as vcp source files).
    You can check these and reorder if necessary. Alternatively, if you start from a prg, you can put the set classlib ... additive commands in there.



    Q:
    I have an existing application written in VFP 9 and this app is using Ms SQL 2012 for data storage. This DB has a lot of stored procedures and triggers - a huge amount of business logic is written there.
    I'd like to use this database and build new user interface from scratch (Desktop, Mobile) using Lianja. To my surprise Lianja is not "using" ODBC to read/write data but it can import data and/or create virtual tables (I'm not sure what's the usage of virtual tables)
    I've played with virtual tables from ODBC and also import from ODBC but neither option seems to be good in my case. Correct me if I'm wrong but looks like Lianja is always using it's own database so I won't be able to save the data back in Ms SQL.
    If that's the case how can use Lianja for my project ? Should I convert my database to Lianja SQL ? Is it possible to transfer all the complicated code written in T-SQL (SP, triggers) into Lianja SQL or I will have to write it from scratch ?
    A:
    The 'Import from ODBC' imports the structure/data of the remote tables into a local native Lianja database, so not what you want.
    Virtual Tables are what you want - they comprise a connection to the remote data, a local 'virtual' table and a cursor adaptor object.
    Using
    Virtual Tables, you design as if you were using local native Lianja data, but you read/update the remote data source via ODBC.



    Q:
    problem when try to run a form from the console, it ask for baseform class which is a build in class in vfp so i can't import it.
    A:
    Add the definition to your form (before baseform is referenced):

    Code:
    define class baseform as form
    // ... any properties/methods you want to set
    enddefine


    Q:
    Error:
    thisform.controls(X1).LEFT=IIF(THISFORM.CONTROLS(X 1).TAG=' ',thisform.controls(X1).LEFT*M.SCRSZ,thisform.cont rols(X1).LEFT)
    A:
    Code:
    ...
    oCurrctrl = thisform.controls(X1)
    oCurrctrl.LEFT=IIF(empty(oCurrctrl.TAG),oCurrctrl.LEFT*M.SCRSZ,oCurrctrl.LEFT)
    ...


    I would recommend running your forms using DO or DO FORM from the Console Workspace first. That way if any errors are reported, you can see what's happening (and as Dave says, submit a ticket if you need us to look into it). Once you are happy with the behaviour of a form run from the Console, trying loading it as a new page from the Form Tools -> Page -> VFP Forms -> *.scp.
    The Form Tools -> Sections -> Custom -> Visual FoxPro allows you to code a Section.



    Q:
    Error: DEFINE class 'MNU1' AS 'MNU'
    A:
    Lianja does not support quotes around the class and baseclass names. Please try modifying the line to:

    Code:
    DEFINE class MNU1 AS MNU


    Q:
    Thisform. Do the VFP references still work ? thisform.GRID1.COLUMNS(A).header1.CAPTION=iif(empt(CONTROL.CAP),TRIM(field_name),trim(CONTRO L.CAP))
    A:
    Yes, if you are running a VFP form - scx imported to scp or program.
    You use Lianja.get("page.section").grid to reference standard Grid sections created from the Form Tools or drag 'n' drop.



    Q:
    how to run an application imported from VFP.

    A:
    Once you have imported the files (http://www.lianja.com/documentation/...l-FoxPro-files), first try running them from the Console Workspace using DO or DO FORM. See how these run and look out for any error messages in the Error Window. You can also use the Debugger in the App Inspector (http://www.lianja.com/resources/blog...ck-start-guide).
    Once you are happy with how they run from the Console, try the embedded Page functionality - in the Pages Workspace from the Form Tools -> Page you will find a list of your imported scx (imported as scp) files. Select these to create a Page in your App with the Form code embedded.



    Import the database in the Data Workspace in the App Builder, then use the Deploy Workspace to deploy it to the Lianja SQL Server data directory.



    The first thing you do is import the individual vcx files.
    Once they are imported they will exist in source code as vcp files.
    you then need to arrange the SET CLASSLIB commands to load the class libraries in the correct order so the compiler knows about the classes when it is parsing.



    if you are sub-classing another class it must be defined above in the file.



    Please make sure that you are in the "Apps" workspace as selected from the left side of the screen.

    Name:  Image.jpg
Views: 1309
Size:  76.3 KB



    ​All topics in [Answers] alphabetically:http://www.lianja.com/community/show...ll=1#post12352
    Last edited by josipradnik; 2016-03-09 at 04:04.

  2. #2
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    Did you import the .scx file? If you did you will have a .scp file in your App folder. You can just run the form using the "do" command from the console.
    However, there was an issue importing scx files correctly in Beta10 which we have fixed in Beta11 which we expect to release soon.
    After you have tested that your form displays and works as expected in the console. you can then "embed" the form inside a "Custom Section" in a "page" in the "page attributes" dialog.



    After using the dbc importer, you will have a Lianja database with your tables and production indexes. You can then access these with OPEN DATABASE, SQL statements and USE and other NoSQL commands from the Console, scripts and programs or using drag and drop and attribute assignment in standard Lianja sections.

    After using the pjx/vcx/scx importer you will have the source code for your scx (renamed to scp), vcx (renamed to vcp) and prg files grouped in an App. These files can then be called with DO, SET CLASSLIB, SET LIBRARY etc from the Console or other programs. Try running your starting program/form from the Console with DO and see how you get on.

    Errors are reported in the Error output window and you can get debug tracing if tracking is proving difficult (
    http://www.lianja.com/community/show...d-to-find-bugs). You could also create Custom VFP Lianja sections (http://www.lianja.com/resources/blog...-visual-FoxPro) and reuse relevant parts of your imported code.



    Q:
    To use Lianja, we would envision creating code that would look for the presence of a .dbc file. If none is found, the code would create a Lianja database file. Then it would import/convert the old .dbf file into a Lianja table via an import command. Does such a command exist or can one be created?
    A:
    Lianja provides a FILETYPE() function and a CONVERT command so you could USE the table in question, check the FILETYPE() and if it's a VFP table CONVERT it to a Lianja format dbf.
    The basic CONVERT syntax is as follows:
    Code:
    CONVERT DBF <filename>
    <filename> can contain wildcards, so for example:
    Code:
    CONVERT DBF conv*.dbf


    Q:
    How do I import a project, screen, etc.
    A:
    Just drag the .pjx .scx or .vcx file onto the "Files" explorer panel in the "Apps" workspace.



    Create an "App" with whatever name you want.
    Drag the .pjx file (or .scx or .vcx file) onto the "Files" panel and it will import the .scx and .vcx files creating .scp and .vcp files. These are just normal .prg files with a special extension to distinguish them from normal .prg files. You can now double-click on them and edit them.
    You can then see what works and what does not in those forms and class libraries.
    Class libraries are nothing special, just use SET PROCEDURE TO name.vcp to make the classes available.
    Forms are just .prg files so just DO FORM name.scp



    After reading through your many posts it seems to me that your focus is on working the way you used to with VFP.
    You stated earlier that you are interested in Lianja for web and mobile in the future.
    if you continue down this road of wanting to hand code your own classes that subclass other classes etc etc then that goes completely against the basic principles behind Lianja app development.

    Why? Because Lianja has a core methodology for building cross platform, cross client applications which VFP does not.

    Applications are broken down
    to consist of many smaller Apps.
    Apps are built out of Pages.
    Pages are built of of Sections.
    There are many prebuilt sections.

    You control the UI by setting attributes.
    You respond to actions using delegates.
    Why? Because this is both scripting language and client (desktop, web, mobile) independent.



    VFP OLEDB is just another ActiveX you can use this in Desktop and Web/Mobile Apps (Cloud Server handles ActiveX in v1.3).

    Code:
    private oConn, oRS, m_count
    oConn = createobject("ADODB.Connection")
    oRS = createobject("ADODB.Recordset")
    lcConnString = "Provider=vfpoledb;Data Source=C:\Temp\Northwind\northwind.dbc"
    oconn.ConnectionString = lcConnString
    oconn.Open()
    oRS.Open("select * from customers where customerid='BOTTM'", oconn)
    m_count = oRs.fields.count
    // display the first record selected
    for i=0 to m_count
        try
            ? "Name=" + oRS.Fields.item(i).Name + ",value=" + etos(oRS.Fields.item(i).Value)
        catch
            // ignore error from Memo
        endtry
    endfor
    Notice how you must use the item() method on the Fields property as this is exposed only as a property not a method.
    The output produced is as follows:

    Code:
    Name=customerid,value=BOTTM
    Name=companyname,value=Bottom-Dollar Markets                   
    Name=contactname,value=Elizabeth Lincoln             
    Name=contacttitle,value=Accounting Manager            
    Name=address,value=23 Tsawassen Blvd.                                          
    Name=city,value=Tsawassen      
    Name=region,value=BC             
    Name=postalcode,value=T2F 8M4   
    Name=country,value=Canada         
    Name=phone,value=(604) 555-4729          
    Name=fax,value=(604) 555-3745
    Note: There is a known issue with retrieving memo fields using the VFP OleDB driver which is why I used TRY/CATCH to ignore the error.




    ​All topics in [Answers] alphabetically:http://www.lianja.com/community/show...ll=1#post12352
    Last edited by josipradnik; 2016-03-09 at 03:37.

  3. #3
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    Q:
    I have import a vfp forms. Our project forms are very extensive, but I see only a text file and not the form like at microsoft visual foxpro.
    A:
    The Lianja importers for Visual FoxPro vcx and scx files output as source vcp and scp files. Any modifications should currently be made in the source code.
    A Visual Form/Dialog Builder that works with existing VFP scx and vcx files is on the Lianja Development Roadmap for v2.4.



    Q:
    I have import an scx formset. If I go to the point "pages" and want to add the form to the page
    A:
    Before adding it as a Page, try running it from the Console Workspace Lianja/VFP Command Window with
    Code:
    do form yourform.scp
    Any errors will be reported in the Error output window.



    A "Code page" in Microsoft Windows is used to represent text in non-english languages.

    For modern applications UTF-8 is the preferred encoding as this is better understood by web browsers.
    UTF-8 is a muti byte character encoding of Unicode that can represent any language and is device and operating system independent.
    Most VFP developers have used localized code pages e.g. german, french, etc so the data that they have in their databases is code page specific.

    We recommend that you use UTF-8.
    A number of developers have requested a way of converting their databases from code page data to UTF-8 so I have added this functionality into v2.0.
    I would recommend that you make a copy of your database first and convert that copy. If all looks fine then you can perform the conversion on your real database.

    The following steps describe the process for data conversion.

    Step 1
    Open the App Builder

    Step 2
    Copy the database

    Step 3
    Code:
    convertutf8 database barry
    The screen shot below shows you that initially any code page data cannot be displayed as I have en_US has my data locale. The chr(220) is a german Ü character in the german code page.



    After conversion completes you should now add the --utf8 command line switch to the Lianja desktop shortcut.



    Run the App Builder now with the --utf8 command line switch and you can now see that the data is now displayed as Unicode as the data is now stored in UTF-8 format.






    Q:
    I was trying to use some gui in App builder but did not see any option there. A database import option is there but nothing for a single vfp table.
    A:
    With an open Lianja database, you can use the Add table or drag 'n' drop in the App Builder Data Workspace, then Deploy for Lianja SQL Server access.
    See the 'Importing Free Tables' section here. The screenshots are from before the databases and tables were put into separate tabs, but it works the same.





    ​All topics in [Answers] alphabetically:http://www.lianja.com/community/show...ll=1#post12352

  4. #4
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    Q:
    I need to import a free vfp table to one of my lianja sql server database.
    A:
    Lianja can open and read vfp tables so you should just need to...
    Code:
    open database your_lianja_database
    use full_path_to_vfp_table
    copy to table_name
    use
    dir
    the table should now be in your database.



    Q:
    A database import option is there but nothing for a single vfp table.
    Is this possible in App builder without using command window ?
    For related cdx file creation
    Copy to table_name with production
    Or
    Copy to table_name with cdx
    Will both work for cdx file creation?

    A:
    Code:
    copy with production 
    will create the indexes too if you need them.



    Although lianja can import vfp tables I do not recommend accessing then directly. Also nowhere have I said we support writing to them.
    Lianja indexes are a completely different format to those of vfp.
    They are fully balanced B+ trees that are optimized for good concurrent access so they contain some additional information which is used internally.
    Lianja has a 64-bit database engine so file size poses no issue.
    Indexes are structured in such a way that the nodes have pointers to their children and parent nodes. Seeing as Lianja handles 64-bit file access v VFP 32-bit file access, the Lianja files will be larger as they accommodate 64-bit pointers.



    If the application is 32-bit (e.g. VFP) and you are loading 32-bit OCX controls that will still be ok.
    If the application is 64-bit (e.g. Lianja App Builder x64 version) then you can only open 64-bit OCX controls inside it.



    I've had a few people asking me if the x86 (32-bit) version of Lianja has a 2GB file limit like VFP and the answer is no it does not.

    The Lianja (both x86 and x64) database engine has built-in 64-bit file I/O so files can be up to 2^64.

    Any product that uses the VFP runtime or the VFP API or in any way maintains database access to be compatible with the VFP table format will be limited to 2GB. This is precisely why you must import your VFP databases into Lianja. If you are building web-scale applications you can rapidly exceed a 2GB file size limit which is the legacy of older database engines. And yes we have customers with tables / memos in excess of 100GB in size already in production.



    Q:
    I have an app containing approx 70 tables and 130+ local views.
    Lianja does not import a DBC's local and remote views.
    I assume that it is possible in Lianja to replace a DBC's views with local and remote virtual tables.
    how to work around the absence of views?
    A:
    The importers that are used to import databases and projects are all written in Lianja and the source code of these is included in the distribution. Look in the library directory for all files like vfp_import_*.prg.

    There is no reason why views could not be imported and a Virtual Table definition created for them insofar as the base tables are imported also. It's probably not a difficult task to accomplish as all the hard work is done in the vfp_import_dbc.prg script. All that is required is to recognize a view then create a virtual table with the same name as the view.

    Code:
    CREATE VIRTUALTABLE viewname CONNSTR "local" AS sql_select_command
    A "local" CONNSTR causes the CursorAdapter to execute the SQL SELECT locally using the embedded database engine rather than connect remotely.

    The ALTER VIRTUALTABLE command can be used to alter any of the clauses used in the CREATE TABLE command including altering any properties such as those that exclude columns and define the basetable for inserts and updates.

    Special note: Remember a dbc database container in VFP is just a regular table so you can USE "fullpath_name.dbc" and inspect all of the columns from the console. Also, in Lianja you can inspect memo fields just by issuing ? nameoffield in the console.



    Q:
    I have this existing tables in dbf format. How could I import it to lianja so that I can use/access it without creating the tables again?
    I tried to copy it on the lianja\data folder but upon opening lianja app builder, it is not found on the data work place.
    A:
    Drag and drop them in the data workspace. They will automatically be converted to Lianja format and added to the active database.
    VFP database/table import does not import triggers. You have to create them using the ALTER TABLE command and place the trigger code in the database container directory.





    ​All topics in [Answers] alphabetically:http://www.lianja.com/community/show...ll=1#post12352

  5. #5
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    Class Files are .vcp files containing class definitions. If you import a Visual FoxPro .vcx class file, the imported source is saved as a .vcp file.



    Q:
    When I run the page in web app view it is blank. I have also created a page with a custom section using the code from http://www.lianja.com/doc/index.php/..._Visual_FoxPro and that does not display in the browser either. I have tried to view in tablet app view and that is also blank. Does vfp code only work for desktop ?
    A:
    Visual FoxPro Custom Sections are supported in the desktop client only.
    Non-UI Lianja/VFP code can be used in server-side prgs and rsps




    Q:
    1. This question is about a conversion of an existing VFP application without rewriting into the Lianja vision.
    2. No pages or sections are created; a form is placed on the screen and is filled by processing metadata.
    3. The business rules or validation methods for each form are accessed by determining what object is being processed.

    The problem i am trying to conquer is that I so far have found no crash proof way of identifying the current object.
    I have a set of code I have attached to the form in the keypress method as follows:
    When I find the right event i add code to it to tell the prog what the current object is.

    I suspect if the grid weren't present then the query to active row would also crash.

    Code:
    debugout 'CONSO'
    debugout grid1.activerow
    DEBUGOUT grid1.ActiveColumn
    *DEBUGOUT tabindex
    *DEBUGOUT this.activecontrol
    GROW=grid1.activerow
    GCOL= grid1.activeCOLUMN
    debugout mcurobj
    IF GROW=0 Or GCOL=0
    DEBUGOUT 'EXIT CONSO NULL GRID'
    *debugout this.baseclass
    RETURN
    ENDI
    NFLD=grid1.column(gcol).controlsource
    *DEBUGOUT oldval(grid1.ActiveColumn.controlsource)
    DEBUGOUT THIS.NAME
    retur
    Tabindex, name, activecontrol, baseclass all crash Lianja when they are null or its equivalent. If I could tell that no valid object was in focus,
    A:
    Look at the is_object() function in the doc
    The solution turns out to be simple as many are the correct command is
    This.activeccontrol.name



    Q:
    What happen when I import a DBC from Visual Foxpro? I will have lianja data tables or dbf tables in the app?
    Am planing to program for Desktop, Web and Mobile. Which database is the best option for that? Can I use the Lianja regular files or it is best to use the Lianja SQL database?
    A:
    You will have a lianja Database. after the import. This is the best choice for your apps.
    You will be using the data in Lianja.



    Q:
    Are delegates like the VFP properties or methods?
    A:
    Delegates are similar to VFP event handling procs but they are scripting language independent.



    VT's are like remote views in VFP, but without the hassle.



    Q:
    if a VFP executable can be run from within Lianja
    A:
    if you compile your vfp exe as a COM server, you can instantiate it in a desktop application, and in the cloud server. That can allow you to make function/method calls, etc. from your existing exe.



    ​All topics in [Answers] alphabetically:http://www.lianja.com/community/showthread.php?2717-Answers

  6. #6
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    Q:
    I have an existing project deployed in visual foxpro 5 and i was trying import project for Lianja. I downloaded linja trial for 30 days to make tests because my goal is putting the tables of project in a database so i think lianja could help me.
    So i created an app in visual foxpro and imported my project for there but i can't run the project to see the apllication. how can i do that?

    A:
    Information on Visual FoxPro imports and scripting can be found here: http://www.lianja.com/doc/index.php/...xPro_Scripting, including:
    Importing Visual FoxPro Databases and Tables - http://www.lianja.com/doc/index.php/...ses_and_Tables
    Importing Visual FoxPro Files - http://www.lianja.com/doc/index.php/...l_FoxPro_Files

    Imports of Visual FoxPro projects, classes and forms extract the data from the VFP tables and generate source code scripts in your App. Start from the Lianja/VFP Command Window in the Console Workspace and run your scripts using DO or DO FORM and issue any required SET CLASSLIB or SET PROCEDURE commands to reference libraries.
    Check the Error and Log windows in the Console Workspace for any issues. Your scripts can be edited in the Apps Workspace.

    Form scripts (*.scp) can also be referenced from a Page
    (Pages Workspace -> Form Tools -> Page), in which case they are embedded in a full-Page sized VFP Custom Section in your App.
    To modify the Custom Section, edit the Form script on which it is based, to add other Pages to the App, use any of the wide range of Lianja in-built Sections.

    After using the dbc importer, you will have a Lianja database with your tables and production indexes. You can then access these from the Data Workspace, using OPEN DATABASE, SQL statements and USE and other NoSQL commands from the Console, from scripts and programs or using drag and drop and attribute assignment in standard Lianja sections.

    Note that it is recommended to rebuild your forms using the Lianja visual Page Builder and drag 'n' drop Lianja standard sections and combine these with your existing VFP background business logic code. This, along with being the easiest and quickest way to migrate - providing you write the client event delegates in JavaScript (with Lianja/VFP extensions) - will have the added advantage that you will also be able to run your Lianja Apps on web or mobile devices.

    You will see the source code for your imported project files in the Files explorer in the Apps workspace with your App open. Source from forms will have a .scp extension, source from class libraries a .vcp extension, .prg files remain unchanged.
    You can then run the scripts/programs, edit the scripts, and embed in a Page if required.



    Today user expectations from applications are very different from those VFP days.
    Because of the technology gap I am afraid there is no free lunch in the migration.
    Lianja is "cross" on so many levels (Win/Mac/Linux , LAN/internet/Cloud, desktop/web/mobile...)
    Choosing among standard sections, custom sections and canvas sections...
    VFP/JavaScript/PHP/Python...
    Lianja is huge. "Cross..." and "multi" are a plus, but in the same time it is a problem - because of all complexity.

    Is Lianja for you - it is a tough question. You need to know where you are headed with your apps.
    I suggest you read more about Lianja concept: http://www.lianja.com/community/show...Lianja-concept

    VFP apps need to be broken down to smaller pieces
    and to be rearranged a lot for today modern technologies:
    App Center (and Categories within) -> Apps -> Pages (and Page centers) -> Sections as visual representation of SQL tables...

    What about strict separation of server side computing from the client side computing in our old VFP apps?
    That is why I do not believe in easy importing on button click.
    Do not expect that you will automatically get GUI responsiveness and all to work in web browsers and mobile.

    Starting from scratch, at least, we can use VFP syntax knowledge in delegates and progress step by step in converting our apps.
    Your VFP knowledge are very valuable and useful here, unlike in some other alternatives where you need to learn completlly new syntax.
    Advice? Do begin with some small part of your complex app and see how are you doing.



    The (single) most important document you should read before you start developing Apps in Lianja.
    Developers Guide
    Lianja Documentation Wiki




    All topics in [Answers] alphabetically: https://www.lianja.com/community/sho...ll=1#post13748

    These answers are also systematized on the site "Lianja developer": https://lianjadeveloper.wordpress.co...vfp-migration/

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us