TOPIC: Error using ChooseListControl
#1640
Error using ChooseListControl 9 Months, 1 Week ago
I'm trying to retrieve data using ChooseListControl and I have the next script:

Field_tipotelefono

Field_string
{
Prompt: 'Tipo de Tel.'
Control: (ChooseList listField: 'trtipotelefono' listSeparator : ' - ')
}


Rule_trtipoteleno

function ()
{

return QueryList('trelleno where tabla_name = "trtipotelefono" join trellenodet',
'descripcion'$" - "$'codigo')
}

But when I am executing Check syntax, Suneido show the next message

Run: run all failed: Querry:syntax error trelleno where tabla_name= “trtipoteleno”
join trellenodet summarize list descripc

1) I want to display descripcion and codigo columns, using list separator “-”.
2) I want to save in the table only codigo column, Is correct the definition in the field?

What is the problem?, I am working with Suneido Built: Oct 30 2009 14:31:55(VC 7 Release)
 
 
#1641
Re:Error using ChooseListControl 9 Months, 1 Week ago
It looks like you hit Run instead of Check Syntax based on the error.

QueryList requires a single field name for the second argument.

And I think ChooseList works the other way - it saves the part before the separator.

So you need something like:

QueryAll("...").Map!({|x| x.codigo $ " - " $ x.descripcion})

Or you could define a rule that combined the two fields and then use QueryList on that rule.
 
 
andrew
 
#1642
Re:Error using ChooseListControl 9 Months ago
Thanks Andrew!!!. But I have a little problem look at the attached file please.
 
 
Last Edit: 2009/11/19 22:46 By isi_jca.
 
#1643
Re:Error using ChooseListControl 9 Months ago
Thanks Andrew!!!. But I have a little problem look at the attached file please.
File Attachment:
File Name: How_to_see_descripcion_and_save_code.zip
File Size: 41750
 
 
#1644
Re:Error using ChooseListControl 9 Months ago
I have not looked at your attachment but the name gives me a clue.

ChooseList does not let you display the description but save the code. It displays what it saves.

I am not sure why we do not have this option - it seems obvious.

It is not hard to implement - mainly you need to override Get, Set, and NewValue. Here is a quick example:

Code:

ChooseListControl
    {
    New(list)
        {
        super(list)
        .map = Object()
        for s in list
            {
            x = s.Split(' - ')
            .map[x[1]] = x[0]
            }
        }
    Set(value)
        {
        prompt = .map.Find(value)
        .Field.Set(prompt is false ? value : prompt)
        }
    Get()
        {
        return .map.GetDefault(.Field.Get(), '')
        }
    NewValue(value)
        {
        .Field.Dirty?(true)
        .Send("NewValue", .Get())
        }
    }

 
 
andrew
 
#1645
Re:Error using ChooseListControl 9 Months ago
Thanks!!!, will be wonderful if you add this functionality in the next release. I will try override ChooseListControl.
 
 
#1649
Re:Error using ChooseListControl 9 Months ago
I was reading the manual, I can't find, how to override a control, or extend it. where can I get an example?. Thanks!!!.
 
 
#1650
Re:Error using ChooseListControl 9 Months ago
I would just make your own control e.g. MyChooseListControl with the code I gave.

If you do want to redefine a control, you can just put the code in your library with the same name as the control you are overriding, and then inherit from _Name (where Name is the name of the control you are overriding). But you have to be careful because if you redefine a standard control you may break things.
 
 
andrew
 
#1657
Re:Error using ChooseListControl 8 Months, 4 Weeks ago
I was intended to override a class using an example: There is a class called ClaseA (item)

//script
class
{

New(x= 0, y = 0)
{
.x = x
.y = y
}
Suma()
{
Print ('Resultado '$(.x + .y));
}
Producto()
{
Print ('Resultado '$((.x) * .y));
}
}

Other Class called ClaseB(item)

//Script
_ClaseA // La ClaseB sobreescribe el método Suma y agrega un nuevo método Division
{
Suma(a = 0,b = 0)
{
return a*2 + b*2
}
Division() // New member no present in ClaseA
{
return (.x /.y)
}
}

When I try to compile, I get the next message: run all failed: can't find Suma. What is the problem?. Where is the error in the code?

Thanks!!!
 
 
#1660
Re:Error using ChooseListControl 8 Months, 4 Weeks ago
ClaseB should just inherit from ClaseA, not _ClaseA

You only need _ClaseA if you have ClaseA (same name) in two libraries and one needs to inherit from the other.

Otherwise it looks ok, except the two definitions of Suma do not seem to be related (but that will not cause an error).

Oops. I decided I better test it. The problem is the comment between ClaseA and the opening curly brace {. If I remove (or move) the comment, then it compiles ok.

I am not sure why the comment is a problem - the parser must be looking ahead for the { and not skipping comments.
 
 
andrew