Connecting 2 variables to write to a text file

Connecting 2 variables to write to a text file

MBestSNZMY
Contributor Contributor
392 Views
5 Replies
Message 1 of 6

Connecting 2 variables to write to a text file

MBestSNZMY
Contributor
Contributor

All,

 

I know this has to be easy....for most.  I haven't figured out the combination yet.

 

I simply want to connect 2 var's and post them in a text file.  I can do the file part easy.  Connecting these 2 have not been for me.  In vba I can do it but these lines will be in an .scr file.

(setq GetDwgName (getvar "dwgname"))

(setq xLim (getvar "limmax")

(setq FileName (open "D:\\Test Folder\\new_4-20.txt" "w"))

(Setq FText (GetDwgName + " " + xLim))

(write-line (FText) FileName)

(close FileName)

In the text file I want it to read

12345.dwg <space> 11.00 8.00

 

Thanks,

Mike

 

 

0 Likes
393 Views
5 Replies
Replies (5)
Message 2 of 6

paullimapa
Mentor
Mentor

Try this

(Setq FText (strcat GetDwgName " " (rtos (car xLim) 2 2) “ “ (rtos (cdr xLim) 2 2)))


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 3 of 6

mbest
Enthusiast
Enthusiast

The error:

; error: bad argument type: numberp: (8.5)

0 Likes
Message 4 of 6

paullimapa
Mentor
Mentor

oops, my mistake..try this modified:

(Setq FText (strcat GetDwgName " " (rtos (car xLim) 2 2) " " (rtos (cadr xLim) 2 2)))

Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 5 of 6

Kent1Cooper
Consultant
Consultant

@MBestSNZMY wrote:

....

(setq xLim (getvar "limmax")

....


That line is missing its closing right parenthesis.

Kent Cooper, AIA
0 Likes
Message 6 of 6

Sea-Haven
Mentor
Mentor

My attempt

 

(setq xLim (getvar "limmax"))
(Setq FText (strcat (Getvar 'DwgName) " " (rtos  (car xlim) 2 2) " " (rtos  (cadr xlim) 2 2) ))

or

(Setq FText (strcat (Getvar 'DwgName) " " 
(rtos  (car (getvar 'limmax)) 2 2) " " 
(rtos  (cadr (getvar 'limmax)) 2 2) ))

or

(setq FileName (open "D:\\Test Folder\\new_4-20.txt" "w"))
(write-line (strcat (Getvar 'DwgName) " " 
(rtos  (car (getvar 'limmax)) 2 2) " " 
(rtos  (cadr (getvar 'limmax)) 2 2) )
filename)
(close filename)

 

0 Likes