Custom libraries are loaded internally and are not affected by SET PROCEDURE TO in any way at all.
This is another reason why I recommend their use.
No I’m referring to the custom library for the App itself.
Go into App settings.
Scroll down the attributes to the delegates.
There is a custom library that gets automatically created if you create an init, load, ready, unload, inactive delegate.
Editing that custom library lets you add your own functions.
There is a custom library for each App, Page and Section. That’s where the delegates live.
Custom libraries are automatically opened when the App is loaded. They are monitored for changes for you and recompiled and reloaded. This is a fundamental part of the Lianja App Builder development cycle. There is no explicit compile or build required.
My recommendation would be to place these functions in the App custom library rather than an external library loaded with SET PROCEDURE TO.
Why? Because lianja knows when any of these files have been edited and automatically recompiles and reloads them. That is not the case with SET PROCEDURE TO. This is exactly what happens when you edit your delegates, custom section code or ,rsp files that generate dynamic WebView content too. There is no compile and build steps required. It is done for you as the whole App is live. The UI knows when files have changed.
Also an advantage to this approach is that it is scripting language independent.
Note also that if you must use SET PROCEDURE TO you can check to see whether the library is already loaded by looking for a “well known function” in the library e.g.
if not function_exists("__mylib__") Set procedure to mylib additive // inside mylib.prg declare an empty function called __mylib__ Endif
// alternatively use require_once() which does all the hard work for you
I realise that sometimes, my changes will not take effect if I run the app immediately after making the changes
I need to load another app and reload back my original app.
May I know if there is a better way to force a refresh so that when I run the app, it will take the latest source files?
If you are using custom libraries these will automatically be recompiled and reloaded if they are edited.
If you have libraries that you are using that Lianja knows nothing about then you will need to save and reload your application for these to take effect.
In Lianja “Procedure libraries” can contain:
Procedures and Functions are essentially the same thing. It’s good practice to use “Function” if it returns a result and “Procedure” if it does not. It’s all down to personal taste.
Script files (.prg) are opened and closed every time you call them. Not a good idea for your own functions. The file should just contain the code.
//myfunc.prg return "Hello world" //mylib.prg function myfunc() return "Hello world"
I have no problem defining multiple functions in libraries but I cannot see how to call these directly from attributes (without having an intermediate prg file as per my first post)
Just edit a custom library, add your function and specify it in an expression:
and in a custom library:
function myfunc() // your code endfunc
Custom libraries are always opened when your app is opened.
When you edit a custom library Lianja detects that it has changed and will reload it automatically and compile it.