PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → [WX19] How to create an optional Procedure parameter of type Control?
[WX19] How to create an optional Procedure parameter of type Control?
Iniciado por guest, 31,ago. 2015 13:04 - 5 respuestas
Publicado el 31,agosto 2015 - 13:04
To create an optional procedure parameter one must specify a default like this:
MyProc(ManadatoryParam is string, OptionalParam is string = "x").

What is the correct syntax for creating an optional parameter which is a control?
OptionalParam is control = ???

Many thanks,

Michael
Publicado el 31,agosto 2015 - 13:26
Hi Michael

use a string, pass the control..fullname, then, in your procedure, either use the name or an indirection on the name, depending on what you need to do and the type of control

Best regards
Publicado el 31,agosto 2015 - 13:36
Thanks Fabrice.

If I declare the procedure as follows:
MyProc(ManadatoryParam is string, OptionalParam is control = "table").

Then I call the procedure like this:
MyProc("mystring", * )

I get the following error:
No control is referenced by the 'OptionalParam' variable.
Use the '<-' operator to reference a control.

Michael
Publicado el 31,agosto 2015 - 14:14
Michael,
I think you can declare it like:
MyProc(ManadatoryParam is string, OptionalParam is Control = Null)
To call it use MyProc("Mandatory String") or MyProc("Mandatory String", MyControl)

In MyProc you can test the OptionalParam to see if it is Null, indicating nothing was passed.
Otherwise it is a control.

Alternatively, if you use the String method then in the MyProc procedure you would need to use {OptionalParam,indControl} when referencing the parameter as a control.
Publicado el 31,agosto 2015 - 14:42
Hi Michael,

Out of my head, something like this should do the trick:
//Call procedure and pass control MyProcedure(EditControl..FullName) //Procedure code MyProcedure(pEditControl is string="") when exception in if not pEditControl ~= "" then if ControlExist(pEditControl) {pEditControl,indControl}..BrushColor=iLightBlue end end ... do ...exception handling here... end
Cheers,

Peter Holemans
Publicado el 31,agosto 2015 - 15:05
Thank you gentlemen.

Michael