Jump to content

setting default values


Guest Valhallan

Recommended Posts

Guest Valhallan

i have numerous popup lists on my DCL/Lisp file and i want to set some of them to a default value. What i end up with though is when the window first opens, i see the desired value, but then it immediately changes to the "0" value of the popup_list.

 

here is the portion of the DCL i think is relevant:

 

: popup_list {

key = "zip_2";

label = "Location 2 :";

value = "1" ;

width = 35 ;

}

 

and here is the portion of the lisp file (again that i think is relevant):

 

(action_tile "zip_2" "(setq slot2 $value)")

(if (= zip " ") (progn (setq zip " ")))

(setq zip (strcase zip))

(set_tile "zip_2" zip)

(if (= slot2 nil)(progn (setq slot2 "1")))

that later on in the program i get

the right default value.

Link to comment
Share on other sites

In your dcl function use this to set the tile. It uses vl functions so remember to add (vl-load-com) to the front of your code. In this example the variable

Gb:Scale is set to a default of 25 in the list. Remember 0 is the first item 1 is the second etc.

Don't declare your variable, so that it will remember the value while you are still in an acad session.

In you dcl example code just use what is shown below and don't show any default values.

 

dcl:

:popup_list {
  label = "Scale of drawing  ";
  key = "Gb:Scale" ;
  }//popup list

 

In the example dcl function:

(setq   Gb:Scale     (nth (read (get_tile "Gb:Scale"  ))Gb:ScaleList);add this line before "done dialog"


;add these lines after  (new_dialog etc....
(setq Gb:ScaleList '(1 2 5 10 20 25 50 100 200 250 500 750 1000 1250 2000 2500 5000 ))
 (start_list "Gb:Scale")
 (mapcar 'add_list (mapcar 'itoa Gb:ScaleList))
 (end_list)
 (if (member Gb:Scale Gb:ScaleList);see if the global variable is an available option in the list
 (set_tile "Gb:Scale" (rtos (vl-position Gb:Scale Gb:ScaleList) 2 0));if it is, set it as default
 (set_tile "Gb:Scale" "5");if not, set the default to 25 (item 5 in list)
 );if


;add this line to your action tile area
(action_tile "Gb:Scale" etc......(you will have to edit to suit) 

 

hope that helps....SF

 

Edit:Looking at your code I am not really sure whether you have a list of items to choose from. Maybe you only have two items?

In which case why are you using a pop up list? A radio button or tick box would be more suitable.

Edited by Small Fish
Link to comment
Share on other sites

Guest Valhallan

ok you lost me. i've never worked with GB:scale and i can't read this and tell where it is actually setting the default value. there are 9 items on that list, used in 6 different pupup_lists, and then i have another list of around 20 items. since i'm going to need to use this code in multiple places for different defaults, i'd like to understand it better before i edit it.

Link to comment
Share on other sites

i've never worked with GB:scale

 

 

This is example code - you will have to do some of the work. If you re-read what I had written you will see that I used "Gb:scale" as an example variable -the list of numbers given needs to edited to suit.

 

i can't read this and tell where it is actually setting the default value

 

 

Again if re read my first post this line sets the default value:

(set_tile "Gb:Scale" "5");if not, set the default to 25 (item 5 in list)

This number (5) in my example sets the default in the popup list (set_tile "Gb:Scale" "5")

in this case the item is "25"

 

 

there are 9 items on that list

What list? I assume you are talking about your list?

If there are 9 items then you list the nine items as shown in the example code

 

 

It seems you have not answered my question as to how many values you have in your list - or you have not given the list in your first post.

Its confusing as to what you are trying to achieve without the list of values.

Maybe a tick box or radio buttons would be better, as it it appears you only have 2 values.

A popup is used when there are three or more values to choose from.

Edited by Small Fish
Link to comment
Share on other sites

Guest Valhallan

Wow. For a place that is supposedly here to be helpful there was a heck of a lot of attitude in that reply. If i didn't understand your example, repeating that its an example doesn't really clarify much, and i'm pretty sure that 9 is more then 3, in most counting systems, so when i say there are 9 items on the list used in 6 different popup lists, 9 values is generally more then 3 values. i have no idea why you keep assuming I only have 2 values to choose from, unless its because the one portion i showed you has the default of the second item on the list.

Link to comment
Share on other sites

For a place that is supposedly here to be helpful there was a heck of a lot of attitude in that reply

 

I am trying to help you, however you make it difficult by not explaining clearly what you want? Its only in your second post you tell me that there are 9 items in your list. Where is your list?

Link to comment
Share on other sites

i have numerous popup lists on my DCL/Lisp file and i want to set some of them to a default value. What i end up with though is when the window first opens, i see the desired value, but then it immediately changes to the "0" value of the popup_list.

 

here is the portion of the DCL i think is relevant:

 

: popup_list {

key = "zip_2";

label = "Location 2 :";

value = "1" ;

width = 35 ;

}

 

and here is the portion of the lisp file (again that i think is relevant):

 

(action_tile "zip_2" "(setq slot2 $value)")

(if (= zip " ") (progn (setq zip " ")))

(setq zip (strcase zip))

(set_tile "zip_2" zip)

(if (= slot2 nil)(progn (setq slot2 "1")))

that later on in the program i get

the right default value.

 

 

Attached is a simple program with two popup list with defaults. They will remember their last selection. I added comments to the areas of your concern.

 

Run the program and study it carefully.

Good Luck

BLKLIB.dcl

BLKLIB.lsp

Edited by The Buzzard
Link to comment
Share on other sites

Valhallan,

 

Please also take note that there are two global variables used in this program. They are global so that they do not lose their value when the program ends.

 

They are:

BLKLIB:SYM ~ Block Library, Symbol global variable

and

BLKLIB:BSF ~ Block Library, Block Scale Factor global variable

 

They are written in this manner to be unique. Because a variable is global, You can run the risk of it interferring with another program that may use the same variable.

I simply add the program name first then a colon, the finally the localized variable name. Since the variable is global it will remember its last value.

 

Localized variables used with the global are:

SYM for symbol and BSF for Block Scale Factor.

 

These variable are declared and lose there value upon program completion.

 

Just thought I would explain this to you so you can use it to compare the results.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...