What is wrong with my popup listbox?

What is wrong with my popup listbox?

gustavobernardi
Advocate Advocate
1,321 Views
6 Replies
Message 1 of 7

What is wrong with my popup listbox?

gustavobernardi
Advocate
Advocate

I think I'm follwing all the steps, but the dcl popup opens empty.

Lisp

(setq mylist (list "RGE" "RGE Sul" "Cermissões" "Nova Palma" "RGE CPFL" "CEEE" "Celetro" "Eletrocar" "Demei" "Creluz" "Hidropan" "Ceriluz" "Coopersul" "Certel" "CELESC" "COELBA" "LIGHT" "CERAÇA" "ENERGISA"))
(set_tile "mylist" defaultlistcasa)
(start_list "mylist" 3)
(mapcar 'add_list mylist)
(end_list)

DCL

: popup_list {key = "mylist"; fixed_width_font = false; width = 20; height = 20; alignment = "centered";}

Result:

popup apagar.JPG

P.S. All the files are on the ANSI format.

TIA

 

 

 

 

0 Likes
1,322 Views
6 Replies
Replies (6)
Message 2 of 7

_gile
Consultant
Consultant

Hi,

 

You should fill the list before setting the selected item by its index.

 

(setq mylist (list "RGE" "RGE Sul" "Cermissões" "Nova Palma" "RGE CPFL" "CEEE" "Celetro" "Eletrocar" "Demei" "Creluz" "Hidropan" "Ceriluz" "Coopersul" "Certel" "CELESC" "COELBA" "LIGHT" "CERAÇA" "ENERGISA"))
(start_list "mylist" 3)
(mapcar 'add_list mylist)
(end_list)
(set_tile "mylist" (vl-position defaultlistcasa mylist))


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 7

_gile
Consultant
Consultant

Sorry the upper reply is not exact, it should have been:

You should fill the list before setting the selected item index converted to string.

 

(setq mylist (list "RGE" "RGE Sul" "Cermissões" "Nova Palma" "RGE CPFL" "CEEE" "Celetro" "Eletrocar" "Demei" "Creluz" "Hidropan" "Ceriluz" "Coopersul" "Certel" "CELESC" "COELBA" "LIGHT" "CERAÇA" "ENERGISA"))
(start_list "mylist" 3)
(mapcar 'add_list mylist)
(end_list)
(set_tile "mylist" (itoa (vl-position defaultlistcasa mylist)))

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 4 of 7

gustavobernardi
Advocate
Advocate

Thanks for the answer. I think your first answer is the correct because "defaultlistcasa" is already a string, based on this part of the code:

(cond 
((= Casa_Read "RGE")(setq defaultlistcasa "0"))
((= Casa_Read "RGE Sul")(setq defaultlistcasa "1"))
((= Casa_Read "Cermissões")(setq defaultlistcasa "2"))
((= Casa_Read "Nova Palma")(setq defaultlistcasa "3"))
((= Casa_Read "RGE CPFL")(setq defaultlistcasa "4"))
((= Casa_Read "CEEE")(setq defaultlistcasa "5"))
((= Casa_Read "Celetro")(setq defaultlistcasa "6"))
((= Casa_Read "Eletrocar")(setq defaultlistcasa "7"))
((= Casa_Read "Demei")(setq defaultlistcasa "8"))
((= Casa_Read "Creluz")(setq defaultlistcasa "9"))
((= Casa_Read "Hidropan")(setq defaultlistcasa "10"))
((= Casa_Read "Ceriluz")(setq defaultlistcasa "11"))
((= Casa_Read "Coopersul")(setq defaultlistcasa "12"))
((= Casa_Read "Certel")(setq defaultlistcasa "13"))
((= Casa_Read "CELESC")(setq defaultlistcasa "14"))
((= Casa_Read "COELBA")(setq defaultlistcasa "15"))
((= Casa_Read "LIGHT")(setq defaultlistcasa "16"))
((= Casa_Read "CERAÇA")(setq defaultlistcasa "17"))
((= Casa_Read "ENERGISA")(setq defaultlistcasa "18"))
((setq defaultlistcasa "0"))
)

And it returns perfectly the number E.g. "15".

The code:

(set_tile "mylist" (itoa (vl-position defaultlistcasa mylist)))

Returns "error: bad argument type: fixnump: nil" because it is not a integer.

The code:

(set_tile "mylist" (vl-position defaultlistcasa mylist))

also returns  "error: bad argument type: stringp nil" 

Even though the "defaultlistcasa" is a string and "mylist" is a list.

(type defaultlistcasa ) STR

(type mylist) LIST

 

 

 

 

 

0 Likes
Message 5 of 7

_gile
Consultant
Consultant

So, if 'defaultlistcasa' is a string representing the index of the item in the list, you could simply do:

(set_tile "mylist" defaultlistcasa)

 

Instead of the (cond ...) expression, you could simply write:

(setq defaultlistcasa (itoa (vl-position Casa_Read mylist)))

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 6 of 7

scot-65
Advisor
Advisor
In your DCL, if you plan to assign a width to a interactive tile, yes,
assign the width but you also need to include fixed_width=true;
in order for this to occur. Otherwise the tile fills the row.

Alternate is to place the interactive tile inside a container [:row {...]
and assign the container as having a fixed width.

I frequently use constants to keep the DCL's total character count down:
//
rfwtac :row {fixed_width=true; alignment=centered;}
//
then:
:rfwtac {popup_list {key = "mylist"; width = 20; height = 20;}}

"fixed_width_font" default value is false and need not be declared.

Other constants I have been known to employ:
swh0;
swh1;
:rfwt {...}
:but12 {key= ; label= ;}

...this is effective as long as the constants are used more than once.

For your dialog, it looks as if the text_part and edit_box can have
constants applied as well [width and edit_width]...

For best results use LSP to set_tile the text_part - this keeps white space minimized:
(setq n 1)
(while (<= n 20)
(set_tile (strcat "Serie" (itoa n)) (strcat "Serie " (itoa n)))
(setq n (1+ n))
);while

???

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

Message 7 of 7

gustavobernardi
Advocate
Advocate

This is my original code:

(set_tile "mylist" defaultlistcasa)

But this really sounds better:

(setq defaultlistcasa (itoa (vl-position Casa_Read mylist)))

Now I see what was worng, I was defining the list before loading the dcl. (just trying to change the oxen-wagon order)

 

0 Likes