Nickvnlr Posted March 13 Share Posted March 13 I created a LISP to output data to a text file. It works well except how do I put spaces in the data? It uses the space as an enter. (defun c:WriteProjectInfo () (setq OutputFile (getfiled "Save Project Info" "" "txt" 1)) ; Prompt user for output file path (if OutputFile (progn (setq Client (getstring "Enter client name: ")) (setq Location (getstring "Enter location: ")) (setq Crop (getstring "Enter crop: ")) (setq DateCode (getstring "Enter date code: ")) (setq Acres (getstring "Enter acres: ")) (setq PlantCount (getstring "Enter plant count: ")) (setq AppRate (getstring "Enter application rate: ")) (setq FileHandle (open OutputFile "w")) (write-line (strcat Client) FileHandle) (write-line (strcat Location) FileHandle) (write-line (strcat Crop) FileHandle) (write-line (strcat DateCode) FileHandle) (write-line (strcat Acres) FileHandle) (write-line (strcat PlantCount) FileHandle) (write-line (strcat AppRate) FileHandle) (close FileHandle) (prompt (strcat "Project information saved to " OutputFile)) ) (prompt "File selection canceled.") ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Steven P Posted March 13 Share Posted March 13 (getstring T "Enter Clients Name: ") 1 1 Quote Link to comment Share on other sites More sharing options...
Nickvnlr Posted March 13 Author Share Posted March 13 Awesome. Thank you! 1 Quote Link to comment Share on other sites More sharing options...
mhupp Posted March 13 Share Posted March 13 AutoDesk has this lookup for functions that usually gives more context for commands. Quote Type: T or nil If supplied and not nil, this argument indicates that users can include blanks in their input string (and must terminate the string by pressing Enter). Otherwise, the input string is terminated by entering a space or pressing Enter. 1 Quote Link to comment Share on other sites More sharing options...
BIGAL Posted March 14 Share Posted March 14 Your welcome to use multi getvals it will make a dcl on the fly for your input of values. If make mistake can correct before hit Ok.Multi GETVALS.lsp (if (not AH:getvalsm)(load "Multi Getvals.lsp")) (setq lst (list "Please enter values " "Enter client name: " 20 19 " " "Enter location: " 20 19 " " "Enter crop: " 20 19 " " "Enter date code: " 20 19 " " "Enter acres: " 20 19 " " "Enter plant count: " 20 19 " " "Enter application rate: " 20 19 " ")) (setq ans (AH:getvalsm lst)) ; ans is a list of the values you can set to a vataible or use (nth x ans) in your write line ps start at x=0 1 Quote Link to comment Share on other sites More sharing options...
Nickvnlr Posted March 15 Author Share Posted March 15 On 3/13/2024 at 5:33 PM, BIGAL said: Your welcome to use multi getvals it will make a dcl on the fly for your input of values. If make mistake can correct before hit Ok.Multi GETVALS.lsp (if (not AH:getvalsm)(load "Multi Getvals.lsp")) (setq lst (list "Please enter values " "Enter client name: " 20 19 " " "Enter location: " 20 19 " " "Enter crop: " 20 19 " " "Enter date code: " 20 19 " " "Enter acres: " 20 19 " " "Enter plant count: " 20 19 " " "Enter application rate: " 20 19 " ")) (setq ans (AH:getvalsm lst)) ; ans is a list of the values you can set to a vataible or use (nth x ans) in your write line ps start at x=0 That's a great upgrade. Works well. I am feeling really dense, but where do I change the input box size? I read this: ; the input box size can be bigger just change the two values tested with 145 145 and worked ok. and cannot figure it out. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted March 17 Share Posted March 17 20 19 is what your looking for, I dont know why 2 values, a min max thing, as suggested in code tested with 145 144, its number of characters in the edit box. You can make each edit box a different size like 4 3 for say 1-10 then 30 29 for a big string. A further hint if you set a variable to say a number you can use that variable in the lst (setq lst (list "Please enter values " "Enter client name: " 20 19 " " "Enter location: " 20 19 " " "Enter crop: " 20 19 "10" "Enter date code: " 20 19 " " "Enter acres: " 20 19 " " "Enter plant count: " 20 19 " " "Enter application rate: " 20 19 "20")) (if (= apprate nil)(setq apprate 20)) (setq lst (list "Please enter values " "Enter client name: " 20 19 " " "Enter location: " 20 19 " " "Enter crop: " 20 19 " " "Enter date code: " 20 19 " " "Enter acres: " 20 19 " " "Enter plant count: " 20 19 " " "Enter application rate: " 20 19 (rtos apprate 2 0))) 2 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.