Jump to content

Using variable value as text?


ShadyV

Recommended Posts

I have been searching for days. I apologize if this is very basic. I don't know terms or coding at all I just type things in lisps until they do what I want. I don't know how to ask the question so that is probably why I can't find the answer by searching.

 

How do I use the RW value in a command line to draw a line? I want to start the line at 0,0 and end at 0,26.  

(setq RW 26)  ;user set value from dcl 

(Command "line" "0,0" "0,RW" "")

How do I place the RW in there so the result is this?

(Command "line" "0,0" "0,26" "")  

 

 

Link to comment
Share on other sites

So... if you put something between  " it is read as a string, a fixed thing and no calculation is done to work out what it is. You'll need to write it out so that the LISP knows to evaluate that part. 

 

To make a point you can use a list, instead of "0,RW" try (list 0 RW)

(Command "line" "0,0" (list 0 RW) "")

 

a second way to do this might be to create a string something like:

 

(setq pt (strcat "0," (rtos RW)))
(command "line" "0,0" pt "")

Here you are making a text string, pt, since RW is a number (or should be?) you need to convert that to a string to join to another string, which is what RTOS does. The reverse is true, if RW is text, and not a number in my first example you;d need to use ATOF

Second note here, (strcat "0," (rtos RW))can be put in place of pt in the second line to make your code a bit shorter.

  • Like 1
Link to comment
Share on other sites

Thank you both. All the options work for me! To stay true to my horrible programming style I will chose the most complex way to put this in and keep my code as long and ugly as possible. lol

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