Jump to content

List a variable value in command line.


uuoo10levi

Recommended Posts

Is it possible to list a variable value in the command line. For example using single line text after you pick your base point it prompts "Specify height :". I want to know if I can put the textsize variable or any other value into a setq value since its always changing and when I run a command I will see the current value set to that variable.

 

Thanks!

Link to comment
Share on other sites

Is it possible to list a variable value in the command line. For example using single line text after you pick your base point it prompts "Specify height :". I want to know if I can put the textsize variable or any other value into a setq value since its always changing and when I run a command I will see the current value set to that variable.

 

Thanks!

 

If I understood correctly, perhaps something like this

 

(setq txth (getreal (strcat "Specify height <"(rtos (getvar 'TEXTSIZE))">: " )))
(if (not txth) (setq txth (getvar 'TEXTSIZE)))

 

Henrique

Link to comment
Share on other sites

Just for the sake of terminology, what you were looking for is to prompt user with default value.
Yeah, and it wouldn't really be a command either.

 

If the solution is correct, then you might allow the user more input leeway and also save the default rather than getting the variable twice, though I cannot say how fast or efficient either is these days.

 

(setq DefaultTextHeight (getvar "TEXTSIZE")
       UserTextHeight (cond
          ( (getdist (strcat
              "\nSpecify height <"  (rtos DefaultTextHeight)  ">: "
          ) )          )
          ( DefaultTextHeight )
)                           )

I'm sure there are even better ways to do this, and in most cases the default should be updated, and perhaps even the system variable.

Link to comment
Share on other sites

Yeah, and it wouldn't really be a command either.

 

If the solution is correct, then you might allow the user more input leeway and also save the default rather than getting the variable twice, though I cannot say how fast or efficient either is these days.

 

As for "allow the user more input leeway", agree, was my failure, were just some quick and dirty code lines, in order to understand the OP needs...

As for "getting the variable twice", I don't see what the problem is, even if it leads to a lack of efficiency(???), is so small, that I don't know if it is worth to creating another variable if you don't need to retain the "TEXTSIZE" System Variable value...

 

I'm sure there are even better ways to do this, and in most cases the default should be updated, and perhaps even the system variable.

 

I fully agree!

 

So, if you don't need to retain the "TEXTSIZE" System Variable value, maybe something like this

(cond
  ((setq NewTextHeight (getdist (strcat "\nSpecify height <" (rtos (getvar 'TEXTSIZE))">: ")))
    (setvar 'TEXTSIZE NewTextHeight)
  )
  ((setq NewTextHeight (getvar 'TEXTSIZE)))
)

 

In case of being necessary to retain the "TEXTSIZE" System Variable value, maybe something like this

(cond
  ((setq NewTextHeight (getdist (strcat "\nSpecify height <" (rtos (setq OldTextHeight (getvar 'TEXTSIZE)))">: ")))
    (setvar 'TEXTSIZE NewTextHeight)
  )
  ((setq NewTextHeight OldTextHeight))
)

 

These would be a way that I would write these code lines, I'm not saying that would be the correct way...

 

Henrique

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...