[Gambas-user] Eval, and "Eval" for assignment?

Benoit Minisini gambas at ...1...
Mon May 26 19:59:52 CEST 2008


On lundi 26 mai 2008, Mike Brett wrote:
> Q1. Why does something like this fail with "Unknown symbol" please?
>
> PRINT Eval("lblMaterial" & "6")

Because Eval() does not use the context of the function where it is executed. 
Eval() is run a global context, it can only use global classes.

>
> Q2. I have a set of consecutively named labels (lblMaterial0,
> lblMaterial1, and so on) to which I want to assign text values from a
> database. Eval() is clearly not designed for assignment purposes, so
> what's the cleanest way to do this in gambas please?
>
> I'm looking for a solution like
>
> FOR EACH dbResult
>    ??Eval??("lblMaterial" & CStr(iC)).Text = dbResult!value

Form class has a Controls pseudo-collection: Form.Controls["lblMaterial" & 
CStr(iC)] will return a reference to the control.

Regards,

-- 
Benoit Minisini




More information about the User mailing list