Results 1 to 4 of 4

Thread: Lianja Python Parameters

  1. #1
    Senior Member
    Join Date
    Oct 2019
    Posts
    325

    Lianja Python Parameters

    With execPython("file.py") I can execute the Python file, which works so far. My question is, can I also access variables created outside of Python? Is it also possible to access the table data set that is currently in focus without having to execute another database command in Python?
    Thanks and greetings Olaf

  2. #2
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,088
    Blog Entries
    22
    You can call Python functions with arguments from LianjaScript.

    See
    https://www.lianja.com/doc/index.php/EXECPYTHON()

    Inside your Python code you can call LianjaScript using:

    Lianja.evaluate( cExpr )

    and

    Lianja.execute( cCommand )

    You can therefore reference cursors and columns in the active record e.g.

    value = Lianja.evaluate(“employees.lastname”)

    In 9.3 the arguments are split into sys.argv[] when the execPython() call is made. This simplifies the LianjaScript/Python integration.


    Code:
    #File: barrytest.py
    import Lianja
    import sys
    
    
    def myfunc(theArg):
        Lianja.writeOutput("myfunc was called with " + theArg)
        return Lianja.evaluate("now()")
    
    
    returnvalue = myfunc( sys.argv[1] )
    Code:
    // call python code from LianjaScropt returning a result
    result = execPython("barrytest.py", "arg1", "arg2", "arg3")
    ? result
    Last edited by barrymavin; 2023-09-24 at 05:55.
    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

  3. #3
    Junior Member
    Join Date
    Jul 2013
    Posts
    11
    execPython("file.py") is not returning returnvalue from the python file to the calling program. On executing the sample code in this thread (barrytest.py) I get the following output:

    myfunc was called with arg1
    .F.

    Deepak

  4. #4
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,088
    Blog Entries
    22
    There was an issue with the return value. I have fixed this in 9.4.7.
    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