Hi Berka, thanks for clarifying details.
UPDATE: Added 4 more "PowerScript dynamic features"
All in all lots of ways to change behavior dynamically.
Only prerequisite: Code must be compiled prior to adding it to running app.
PowerScript is a compiled language, not interpreted unlike JavaScript. Therefore, you don't find Execute( ... ) to dynamically execute strings. ORCA is the technology that actually enables exactly what you are requesting.
Short of ORCA there are several ways to make code "dynamic" in different shapes and sizes:
- Use PB IDE to alter code after original compile time; then apply modified/new code at runtime.
- Use SetLibraryList to modify library list at runtime.
Add libraries and/or change sequence in the library list.
- Deliver some source code PBL files along with your app.
Allows users to modify a subset of classes and DataWindow objects.
- Deliver full app as source code so end-user or third-party can modify everything.
- Use dynamic linking/late binding of external code - albeit these are not PowerScript
- Any C# assembly loaded using new C# interop in PB 2019 R2
- Any COM object referenced via OLEObject
- Any external function call
- Any stored procedure or user-defined function
- User PowerScript dynamic features
- Call events using TriggerEvent/PostEvent - event name is text.
- Call methods using DYNAMIC - late binding at runtime. Watch for exceptions.
- Use Describe( "Evaluate( ... )" ) in DataWindow/DataStore.
- Create DataWindow objects from scratch - full syntax is text.
- Use string variable to determine DataWindow object name.
- Use string variable to determine DataWindow column name.
- CREATE USING "..." to create any class on demand.
- Open/OpenWithParm "syntax 2" to open any window class on demand.
- OpenSheet/OpenSheetWithParm "syntax 2" to open any window class as a sheet on demand.
- OpenTab/OpenTabWithParm "syntax 2" to open any tab page on demand.
- OpenUserObject/OpenUserObjectWithParm "syntax 2" to open any visual user object on demand.
In any case, I must stress using "very dynamic" coding techniques are potential security risks especially when you let user modify code as app is running. How will you do security analysis of code written while app is running?
HTH /Michael
Message.StringParm = "OPEN USEROBJECT" // Indicate its a User Object
IF Right ( Lower(as_object_name) ,6 ) <> "master" THEN // Base name?
ls_name = as_object_name + "_" + go_ac.of_get_language ( ) // NO=>Compute UO 2 open
END IF
li_rc = ao_window_ptr.OpenUserObject ( ao_dragobject_ptr, ls_name , &
ai_x_position, ai_y_position ) // Instantiate UO!
IF go_ac.of_is_debug_mode( ) = TRUE THEN // Debug Mode?
IF go_ac.of_get_client_type( ) = "PB" THEN
PopulateError (0, "Open UserObject - global function" ) // Get object info
END IF
lo_sr.si_data [ 1 ] = ls_name // Load UO name
lo_sr.si_data [ 2 ] = String (li_rc) // Load RC
lo_sr.si_data [ 3 ] = "fn_open_user_object" // Load Function Name
go_ac.of_get_message (71, ls_title, ls_msg, lo_sr) // Get MSG
go_ac.of_write_log (ls_msg) // Write 2 Log!
END IF