Jump to content
rwsice9

Help with making a String

Recommended Posts

rwsice9

Hey everyone. Im having a bit of trouble constructing a string. I have my code working perfectly except for one little thing. I want the middle part of my string to be a variable, set by the user earlier in the code, or reading another USER variable.

 

Here is my code so far:

 
(defun C:titld (/ strRevv )
;'  (vl-load-com)
 (SETQ RV (GETVAR "USERI5"))
 (IF (= RV 0)(setVAR "USERI5" (getint "\nEnter Current Revision Number: ")))
(setq pt (getpoint "\Select Insertion Point: "))
(setq strRevv (getvar "useri5"))
(setq date (strcat "%<[url="file://acsm/"]\\AcSm[/url] SheetSet.REV " "04" " DATE [url="file://f/"]\\f[/url] \"%tc1\">%"))
(setq desc (strcat "%<[url="file://acsm/"]\\AcSm[/url] SheetSet.REV " "04" " DESCRIPTION [url="file://f/"]\\f[/url] \"%tc1\">%"))
(setq initial (strcat "%<[url="file://acsm/"]\\AcSm[/url] SheetSet.REV " "04" " INITIALS [url="file://f/"]\\f[/url] \"%tc1\">%"))

;(setq date (strcat "rev " strrevv " INITIALS"))
(COMMAND "-insert" "rev1t40-d" pt "" "" "" strrevv date desc initial)()
)

 

Notice in each of the date, desc, initial lines there is the "04". What i would like to be able to do is use the value stored in the strRevv variable and make the string out of that number. Is this even possible?

 

Thanks in advance for your time!:D

Share this post


Link to post
Share on other sites
SOliver

For the string section of this you could replace

 

(getint ...... )

 

with

 

(getstring ......)

 

Unless you require it to be an integer in which case you can convert to the value to a string using

 

(rtos <integer value> 2 0)

 

As for the setvar; Can't you use SETQ instead of SETVAR? to store the variable. If it's set prior to calling this function you could always use a global variable.

 

Hope this helps,

SOliver

Share this post


Link to post
Share on other sites
rwsice9

Thanks for the ultra fast reply! I actually figured it out about 10 seconds after i Posted this. As for the SETVAR, i need to use that because I use that same value for other commands as well.

 

Something clicked that I was trying to stick an integer into a string and autocad didnt like it, so I added a (itoa) line in there, along with an IF to check the number and prefix it with a zero if its less than 10.

 

I do appreciate you taking the time to reply!

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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