PC SOFT
DEPOT EN LIGNE
POUR WINDEVWEBDEV ET WINDEV MOBILE

WD Dynamic compilation
Publié par Boller
dans la catégorie Outils
Nouveautés



Description
WD Dynamic compilation


bCompilationResult is boolean

// Starts the compilation of the code
bCompilationResult = CompileDynamicCode()

// If the compilation was successful
IF bCompilationResult = True THEN

// Runs the compiled code dynamically
Execute(DYNAMIC_PROCEDURE)

// The following code can also be used (if the dynamic procedure expects parameters, they must be passed after the <trtProcedure> parameter):
// ExecuteProcess(DYNAMIC_PROCEDURE, trtProcedure)
END

CASE EXCEPTION:
STC_ERROR_COMPILED_CODE = ExceptionInfo(errMessage)

CASE ERROR:
STC_ERROR_COMPILED_CODE = ErrorInfo(errMessage)



//--------------------------------------------------------------------------------------------------------


// Summary: Performs the dynamic compilation of the code
// Syntax:
//[<Result> = ] CompileDynamicCode ()
//
// Parameters:
// None
// Return value:
// boolean: True if the code was successfully compiled, False otherwise
//
PROCEDURE CompileDynamicCode()

bCompilationResult is boolean
sCompilationResult is string

HourGlass(True)

// Compiles the code
sCompilationResult = Compile(DYNAMIC_PROCEDURE, EDT_COMPIL_CODE)

// Checks the compilation result
SWITCH sCompilationResult

// No error
CASE ""
bCompilationResult = True
STC_ERROR_COMPILED_CODE = ""

// Fatal compilation error
CASE "ERR"
bCompilationResult = False
STC_ERROR_COMPILED_CODE = ErrorInfo

// Incorrect code
OTHER CASE
bCompilationResult = False
STC_ERROR_COMPILED_CODE = sCompilationResult

END

HourGlass(False)

RESULT bCompilationResult

//-------------------------------------------------------------------------------------------------------------------------------------------


// The code does not have to be compiled beforehand, EvaluateExpression is doing it.

// Creates the local variables
X is real = 3.14
Y is real = 0.196

// Loads the formula
sFormula is string = EDT_FORMULA_CODE

// Runs the code of the formula: this one returns a value (there is no need to use the RETURN keyword), it cannot expect any parameters, but
// it can access the local variables of the process in which it is run
Info("Result = " + EvaluateExpression(sFormula))

CASE EXCEPTION:
STC_ERROR_EVALUATEEXPRESSION = ExceptionInfo(errMessage)

CASE ERROR:
STC_ERROR_EVALUATEEXPRESSION = ErrorInfo(errMessage)


//-------------------------------------------------------------------------------------

Illustrations, copies d'écran
none
none
Avis des utilisateurs
(Pour noter la ressource, cliquez sur Ecrire un avis)
Aucun avis ou commentaire ? Soyez le premier !