Login






Lost Password?
No account yet? Register
Home arrow Forum
Suneido User Forums
Welcome, Guest
Please Login or Register.    Lost Password?
Error using ChooseListControl (1 viewing) (1) Guest
Go to bottom Favoured: 0
TOPIC: Error using ChooseListControl
#1640
isi_jca (User)
Posts: 27
User Offline Click here to see the profile of this user
Error using ChooseListControl 9 Months, 3 Weeks 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)
 
Logged Logged  
  The administrator has disabled public write access.
#1641
andrew (Admin)
Admin
Posts: 693
User Offline Click here to see the profile of this user
Re:Error using ChooseListControl 9 Months, 3 Weeks 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.
 
Logged Logged  
 
andrew
  The administrator has disabled public write access.
#1642
isi_jca (User)
Posts: 27
User Offline Click here to see the profile of this user
Re:Error using ChooseListControl 9 Months, 3 Weeks ago  
Thanks Andrew!!!. But I have a little problem look at the attached file please.
 
Logged Logged  
 
Last Edit: 2009/11/19 22:46 By isi_jca.
  The administrator has disabled public write access.
#1643
isi_jca (User)
Posts: 27
User Offline Click here to see the profile of this user
Re:Error using ChooseListControl 9 Months, 3 Weeks 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
 
Logged Logged  
  The administrator has disabled public write access.
#1644
andrew (Admin)
Admin
Posts: 693
User Offline Click here to see the profile of this user
Re:Error using ChooseListControl 9 Months, 3 Weeks 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())
        }
    }

 
Logged Logged  
 
andrew
  The administrator has disabled public write access.
#1645
isi_jca (User)
Posts: 27
User Offline Click here to see the profile of this user
Re:Error using ChooseListControl 9 Months, 3 Weeks ago  
Thanks!!!, will be wonderful if you add this functionality in the next release. I will try override ChooseListControl.
 
Logged Logged  
  The administrator has disabled public write access.
#1649
isi_jca (User)
Posts: 27
User Offline Click here to see the profile of this user
Re:Error using ChooseListControl 9 Months, 2 Weeks 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!!!.
 
Logged Logged  
  The administrator has disabled public write access.
#1650
andrew (Admin)
Admin
Posts: 693
User Offline Click here to see the profile of this user
Re:Error using ChooseListControl 9 Months, 2 Weeks 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.
 
Logged Logged  
 
andrew
  The administrator has disabled public write access.
#1657
isi_jca (User)
Posts: 27
User Offline Click here to see the profile of this user
Re:Error using ChooseListControl 9 Months, 2 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!!!
 
Logged Logged  
  The administrator has disabled public write access.
#1660
andrew (Admin)
Admin
Posts: 693
User Offline Click here to see the profile of this user
Re:Error using ChooseListControl 9 Months, 2 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.
 
Logged Logged  
 
andrew
  The administrator has disabled public write access.
Go to top