Jump to content

Recommended Posts

Posted

i had write a simple code like this in notepad

(defun C:draw() (princ "a"))

and i save it as draw.lsp

 

in autocad 2011,i type (load "draw") but it return nil to me ...what it eh problem?

 

i had try to make other .lsp to run n no porblem occur but only this...

Posted
i had write a simple code like this in notepad

(defun C:draw() (princ "a"))

and i save it as draw.lsp

 

in autocad 2011,i type (load "draw") but it return nil to me ...what it eh problem?

 

i had try to make other .lsp to run n no porblem occur but only this...

Is the file in a support path?

What happens if you type (findfile "draw.lsp") ?

Posted

thx for ur reply

i had found the solutions for this problem

i use ctrl+a in notepad to highlight my contents ,many hightlight had appear with no text in it.After i delete the things n leave only the (defun C:draw()(princ"a")) on my program it works.

PS:i dont know y there are invisible hightlightable content shown in my program,meybe cause by tab or space buttons?

Posted

Another silly question to ask:

how do i use write-line function to write variable+string into file?

i try (write-line n+"ss" myoutputfile) and (write-line n&"ss" outputfile) but it doesnt work....

how to princ or write variable and string together in autolisp?

Posted
Another silly question to ask:

how do i use write-line function to write variable+string into file?

i try (write-line n+"ss" myoutputfile) and (write-line n&"ss" outputfile) but it doesnt work....

how to princ or write variable and string together in autolisp?

You have to use the OPEN function first.

Posted

i can and i know how to use write-line function.

my problem is how to write varibale n string into it?

As in other programming language ,we will use varible&"string"(vb) or variable+"string"(vc),how about in autolisp?

i search through begginner guide but no luck ....

Posted

You are looking to perform a string concatenation, so look into the strcat function.

Posted

k,i solve my problem now(ps:is this the only way?caz if my variable is not string type den i had to use convertion(eg:rtos)first den can only strcat the variable and "string" together)

 

my last 2 question ,First,anyway to use write function to output on the same line?

i dont want it to always output it on newline.

 

Second,is autolisp support nested looping?

when i use this code

(while pt1

(if (= n 1)

(write-line "a" outputfile)

(write-line "b" outputfile)

) )

i m sure that the if/while condition and openfile and other things is not wrong but

the write-line "b" wont work for me....maybe i misuse the if function or any syntax wrong for the above 5 lines code?

Posted

Use strcat to concatenate everything you want on one line.

 

To progn to wrap multiple statements to be evaluated as a single argument (similar to wrapping statements in '{' in C++ ).

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