newbievbnet Posted June 12, 2010 Share Posted June 12, 2010 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... Quote Link to comment Share on other sites More sharing options...
alanjt Posted June 12, 2010 Share Posted June 12, 2010 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") ? Quote Link to comment Share on other sites More sharing options...
newbievbnet Posted June 12, 2010 Author Share Posted June 12, 2010 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? Quote Link to comment Share on other sites More sharing options...
newbievbnet Posted June 12, 2010 Author Share Posted June 12, 2010 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? Quote Link to comment Share on other sites More sharing options...
alanjt Posted June 12, 2010 Share Posted June 12, 2010 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. Quote Link to comment Share on other sites More sharing options...
newbievbnet Posted June 13, 2010 Author Share Posted June 13, 2010 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 .... Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 13, 2010 Share Posted June 13, 2010 You are looking to perform a string concatenation, so look into the strcat function. Quote Link to comment Share on other sites More sharing options...
newbievbnet Posted June 13, 2010 Author Share Posted June 13, 2010 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? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 13, 2010 Share Posted June 13, 2010 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++ ). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.