Results 1 to 3 of 3

Thread: [Answers] Procedure

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

    [Answers] Procedure

    use create them in a procedure library and issue:
    SET PROCEDURE TO yourlibraryname in the init or load event for the app.
    You can subclass any of the lianja UI framework classes.
    These classes can then be used in both custom sections and gadgets.



    Q:
    If I use the p_valid.prg as a standalone I must one as part of the script files in the app?
    It would be available for the whole app?
    How would it be to create it as a function inside the function library?
    And finally, sorry for the abuse, if it is part of the page or section where the event would be used to validate input when it loses focus?
    A:
    If it is a standalone prg, just click the + button at the bottom of the 'Files' in the Sidebar in the Apps Workspace and it will prompt you for the filename. The default file extension is '.prg'.
    Yes, it will be available for the whole App. When you Deploy, it will be deployed as a .dbo (pseudo-compiled) file.
    If you have lots of functions you want to use, you can put them in a function/procedure library (create this using the + button as before):


    Then use set procedure to <lib> additive in a delegate called before the function is required, for example in the app.load() or the app.ready() (or a delegate for the relevant Page or Section).



    Or, as in the screenshot above, you can add functions ('anotherfuncstill' here) in with the event delegates.
    The custom libraries for event delegates (created when you create your first delegate) are opened for you automatically; there is no need to use set procedure in this case.

    Pages and Sections can also have a 'Valid When' event delegate called after the field validation.



    ​All topics in [Answers] alphabetically:http://www.lianja.com/community/show...ll=1#post12352
    Last edited by josipradnik; 2017-01-05 at 02:59.

  2. #2
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    Q:
    Say I have a function that returns an array (or datetime, or whatever), if that function fails I want to return null and then check for that null (as you can/would in C#), something like the code below. What are the rules for this in lianja

    Code:
    function test(ok)
      if (ok)
        return array()
      else
        return null
      endif
    endfunc
    
    x = test(.F.)
    if x=null
      //The function failed
    endif
    A:

    Code:
    function test(ok)
      if (ok)
        return array()
    else
        return .null.
      endif
    endfunc
    
    x = test(.F.)
    if isnull(x)
      //The function failed
    endif


    Q:
    it looks like 'tcPassedIn1' is local to 'Test1' and not private:

    Code:
    proc page1_section2_field2_click()       
    local lcTest
    lcTest = "Original String"
            Test1(lcTest)
    MessageBox(lcTest, 0)
    endproc
    
    proc Test1(tcPassedIn1)
    tcPassedIn1 = "Var not overwritten"
    Test2(tcPassedIn1)
    MessageBox(tcPassedIn1, 0)
    endproc
    
    proc Test2(tcPassedIn2)
    tcPassedIn2 = "Var overwritten"
    endproc
    A:
    Parameters in the proc declaration are local as you point out.
    This is not standard VFP, it's another useful extension that reduces typing.
    No need for lparameters... statement



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

  3. #3
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    Q:
    I've a form, with a new container, with a button.
    On the "cick" event, I call a procedure "sp_close_handler"
    Code:
    oContBottom.addObject("sp_close", "commandbutton")
    sp_close.move(1, 1, 60, 20)
    sp_close.text = "Close"
    sp_close.click = sp_close_handler
    
    proc sp_close_handler()
        p_myform.close()
    endproc
    can I send a parameter on the call?
    for example:
    Code:
    oContBottom.addObject("sp_close", "commandbutton")
    sp_close.move(1, 1, 60, 20)
    sp_close.text = "Close"
    sp_close.click = sp_close_handler with "aaa"
    
    proc sp_close_handler(m_text)
        lianja.showmessage(m_text)
        p_myform.close()
    endproc
    naturally, this code not work.. :-)

    A:
    Lianja objects are dynamically extensible so you can define your own properties on the command button,
    Code:
    sp_close.myvar = "something"
    then in the sp_close_handler() just reference this.myvar.
    Note that in Lianja 3.4 you can associate objects with UI components too.
    Code:
    mydataobj = object()
    mydataobj.hello = "world"
    sp_close.mydata = mydataobj
    or
    Code:
    sp_close.mydata = object()
    sp_close.mydata.hello = "world"
    Notice how objects are dynamically extensible.
    then later you can reference the members of objects like this.
    Code:
    sp_close.mydata.hello
    etc.
    and as it turns out you can attach arrays to UI objects also, and arrays can contain objects or other arrays...
    Code:
    declare myarray[10,10]
    myarray[1,1] = "hello"
    btn.myarray = myarray
    ? btn.myarray[1,1]
    ? btn.myarray
    So this allows you to attach business objects to UI controls as all objects and arrays in Lianja are reference counted so going out of scope does not affect them.
    So with some creative thinking you can save and restore business objects and attach them to the UI controls of your apps in the "ready" delegate.




    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...ory/procedure/

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