Welcome! Log In Create A New Profile

Advanced

Dynamic programming

Posted by Niek 
Niek
Dynamic programming
December 30, 2019 03:56PM
Hi,

I like to do some testing with 'dynamic' programming.

In a window i have 2 edit controls (EDT_Code and EDT_Result) and 1 button.
In EDT_Code I want to place some Windev Code for example.
DateSys()

When I click the button i like to get the result in the second control (EDT_RESULT) --> 20191230

In the buttoncode i have the following code.

Formula is Procedure = Compile("Dynamic_Proc", EDT_Code)
IF ErrorOccurred = False THEN
ExecuteProcess("Dynamic_Proc", trtProcedure)
// Other possibility for runing the procedure: Formula()
ELSE
Info(ErrorInfo())
END

I do not have an error but how to get the result in EDT_Result ?
Re: Dynamic programming
December 30, 2019 04:57PM
Hi Niek,

You've probably taken your example from here; [help.windev.com]

...and I'm no expert in dynamic coding, but I would think that your actual Windev code needs to be valid WLanguage code and not just DateSys(). Just having DateSys() as your code doesn't mean anything.

Just off the top of my head and I've not tried this, but I'm presuming your code would need to be something like this wouldn't it?

Procedure Dynamic_Proc()

RESULT (DateSys())

Regards,
Darren.
JP
Re: Dynamic programming
December 30, 2019 05:08PM
Niek

DateSys() on its own will just execute that function but return nothing. In order to return something you would have to do something like:

1) Create a global variable e.g. MyVarDate is date

2) Then in your test code you would write: MyVarDate = DateSys()

3) Then execute that code retrieve the value from the global variable MyVarDate

In other words, the code you Execute() needs to do something and store the result of that something into a global variable or database field or somewhere else where you can subsequently access it.

Or, if you just want to execute a single line of code then use Darren's suggestion and just encapsulate the single line of code like this:

RESULT( DateSys() )

And then say: EDT_Result = ExecuteProcess("Dynamic_Proc", trtProcedure)

JP



Edited 2 time(s). Last edit at 12/30/2019 05:11PM by JP.
Niek
Re: Dynamic programming
December 30, 2019 05:10PM
Thank you thumbs up

it works...

Formula is Procedure = Compile("Dynamic_Proc", EDT_Code)
IF ErrorOccurred = False THEN
EDT_Result=ExecuteProcess("Dynamic_Proc", trtProcedure)
ELSE
Info(ErrorInfo())
END

EDT_CODE=Result Datesys() + Timesys() EDT_RESULT --> '20191230170845345'
pao
Re: Dynamic programming
December 30, 2019 06:22PM
If you need to run the dynamic procedure sevaral times you can use compile, if need to run the code once you can use the ExecuteCode function

We use compile/executecode and ControlCreate to generate some forms,reports and queries. With this functions you can do a lot of stuff.

Regards

Paulo Oliveira



Edited 1 time(s). Last edit at 12/30/2019 06:27PM by pao.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: