Results 1 to 2 of 2

Thread: Nesting Lianja.evaluate to call foxpro and javascript from python.

  1. #1

    Nesting Lianja.evaluate to call foxpro and javascript from python.

    Just thought I would share this one.

    I have a custom VFP section, with a webview control in a container I called alphaweb.
    alphaweb is declared as public variable in my VFP Section.

    I have the URL set to a jssp page that has several javascript functions declared in the jssp page.

    I also have a python library that I am using for some image manipulation.

    The challenge is to call the javascript functions from the python code.
    Normally that's easy, I could use Lianja.get().webview, but recall the webview is in a custom section, so you need to reference it by public variable.

    With a bit of tinkering, I found it was pretty easy.

    Using Lianja.evaluate, I call the foxpro code to call the javascript code from the python code.

    Like so.

    Def procname():
    ----Lianja.evaluate('alphaweb.evaluate("addimage()")')



    I thought it was pretty cool to be able to go back and forth between, the VFP, Python and javascript functions.

    Lianja made that easy.

    Thanks.

    ps - I am sure there is an easier way, but it was still fun.

  2. #2
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,161
    Blog Entries
    22
    Its also worth mentioning that in Lianja 3.1 the execPython( expr ), execPHP( expr ) and execJavaScript( expr ) Lianja/VFP functions return the result of the executed code. This makes it simple to integrate Lianja/VFP with Python/PHP/JavaScript. If expr is a filename it it loaded and executed.

    And also just to remind you.

    1. In Python, PHP and JavaScript you can call Lianja.evaluate( expr ) to call back into Lianja/VFP.
    2. The Lianja/VFP loadLibrary( filename ) function can load Python (.py), PHP (.php) and JavaScript (.js) libraries too.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

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