Welcome to TheSwamp .. see if this sheds any light:
I'd like to start with the first line (the setting of the InitLen variable).
Is that variable already set before this function runs?
If so you can fix the double quote locations and have this line:Code - Auto/Visual Lisp: [Select]
Next I want to talk about the logic behind line two:Code - Auto/Visual Lisp: [Select]is saying:
"If the `Len` variable doesn't evaluate to nothing, set the `initLen` variable equal to the `Len` variable, otherwise set the `Len` variable equal to 4."
Is that the statement you want to make or were you intending something else? My guess, this line is NOT correct so we will have to change it.
Also, note that you can select any BLUE text in the code tags I am using to get help on the function (like SETQ, GETREAL, STRCAT, etc).
----->%
Is there a way to get more information on the 2 0 after the initlen? I assume they have to do with an internal setting, but I haven't found a good resource for what changes.
----->%
Is there a way to get more information on the 2 0 after the initlen? I assume they have to do with an internal setting, but I haven't found a good resource for what changes.
If you click on the RTOS function in the code block you will be brought here: https://www.theswamp.org/Sources/doc/avlisp/#rtos
Which tells you that the 2 is the MODE and the 0 is the precision.
Okay on to the first statement then.
The variable is undefined so you have a choice to make:
- have a default value or not. Meaning, you can control the program with this statement; if the user does not enter a value, your program can gracefully quit OR you can gracefully quit during the GETPOINT portion later.
Here is a demonstration:
1. no default value for `initlen`.Code - Auto/Visual Lisp: [Select]OR a default value (of 4):Code - Auto/Visual Lisp: [Select]Run both (copy paste into the command line) and decide.
; simple draw a box and dimension it
; By Alan H March 2019
' info@alanh.com.au
(defun c:2box ( / pt1 pt2 pt3 ahl ahh ahoff )
(setq oldsnap (getvar 'osmode))
(setq oldang (getvar 'angdir))
(setq pt1 (getpoint "\nPick lower left"))
(setvar 'osmode 0)
(if (not AH:getvalsm)(load "Multi Getvals.lsp"))
(setq ans (AH:getvalsm (list "Enter values" "Length " 5 4 "150" "Height " 5 4 "100")))
(setq ahL (atof (nth 0 ans)))
(setq ahw (atof (nth 1 ans)))
(setq pt2 (polar pt1 0.0 ahl))
(setq pt3 (polar pt2 (/ pi 2.0) ahw))
(command "rectang" pt1 pt3)
(setq ahoff (* 2.0 (* (getvar 'dimasz)(getvar 'dimscale))))
(setq pt4 (polar pt2 (* pi 1.5) ahoff))
(command "dim" "hor" pt1 pt2 pt4 "" "exit")
(setq pt4 (polar pt3 0.0 ahoff))
(command "dim" "Ver" pt2 pt3 pt4 "" "exit")
(setvar 'osmode oldsnap)
(princ)
)
(c:2box)