How to define method or function in macro file

I want to use method or function in macro file, what is the correct way to call and define them?

Just simply I tried like below but error message "variable !THIS does not exist"


define method .test()
$P 'test'
endmethod

!This.test()

  • setup form !!test1 size 10 10

    !this.formtitle = 'test form'

    path down

    button .b1 xmin ymin 'Print' background beige TOOLTIP 'Print' call |!this.test()| width 2

    exit

    define method .test()

    $p 'test'

    endmethod

    keep this in test1.pmlfrm (create a text file rename it to .pmlfrm) 

    keep it in a pmllib under forms

    check your library exists in pmllib through q evar |pmllib|