Suppport files.
INI FILE
;; KDUB_BlockInserter.ini
;; Revise the default PATH and LAYER to suit
[CONFIGURATION]
PATH=F:\VENDOR
LAYER=ST-BLOCKS
LIBRARY STUFF
;;;------------------------------------------------------------------
;;;------------------------------------------------------------------
;;;------------------------------------------------------------------
;;; Return the #<VLA-OBJECT IAcadLayer Object or nil
;;; (kdub:assertLayer "ST25")
(defun kdub:assertlayer (layername / iacadlayer)
(if (vl-catch-all-error-p
(setq iacadlayer (vl-catch-all-apply
'vla-add
(list (vla-get-layers kglobal:activedoc)
layername
)
)
)
)
nil
iacadlayer
)
)
;;;------------------------------------------------------------------
;;;------------------------------------------------------------------
;;;
;|--------------------------------------------------------
Function: KDUB:string->strlist (searchstring delimstring)
DESCRIPTION: Converts string into string list, removing delimiters
Remove delimiter chars such as space , \t \n
ARGS: searchstring : any valid string
delimstring : any valid string
EXAMPLE:
(KDUB:string->strlist "x,,2,3,," ",") =>> ("x" "2" "3")
(KDUB:string->strlist &!34;x,,2,3,," ",x") =>> ("2" "3")
(KDUB:string->strlist (getenv "ACAD") ";") =>> (^_*)
(KDUB:string->strlist "xxxx \tyyy \nzz" " \t\n") ==>> "xxxx" "yyy" "zz")
----------------------------------------------------------|;
(defun kdub:string->strlist (searchstring delimstring
/ tempstring
index tempchar
returnlist delimchars
)
(setq delimchars (vl-string->list delimstring)
tempstring ""
index (1+ (strlen searchstring))
)
(while (> (setq index (1- index)) 0)
(setq tempchar (substr searchstring index 1))
(if (member (ascii tempchar) delimchars)
(if (/= tempstring "")
(setq returnlist (cons tempstring returnlist)
tempstring ""
)
)
(setq tempstring (strcat tempchar tempstring))
)
)
(if (/= tempstring "")
(cons tempstring returnlist)
returnlist
)
)
;;;------------------------------------------------------------------
;;;------------------------------------------------------------------
;;;
;|
acet-ini-get inifile [section [key [default]]])
Retrieve data from INI file.
Arguments
inifile: Name of the INI file to search.
section: Section name within the INI file.
key: Key name within the section.
default: Default value to return if key cannot be located.
Return Values
The return value depends on the parameters provided.
If only inifile is given, this function returns a list of section names
(or nil if inifile cannot be opened).
If a section name is given, a list of key names will be returned.
If a key is given, returns the value associated with the key (or default,
if the key cannot be located). Returns nil if no information can be found.
|;
;;;------------------------------------------------------------------
;;;
;|
(KDUB:iniget-entrylist
< inifile > : as string - fully qualified drive:\\path\\name
< section > : as string
)
ReturnList shall be either :
1 ] association list as (string key . string entryvalue) for entrys in section
2 ] nil if process error , no section , no keys.
KWBrown :- Rev : 2003-Oct-17
For Acad R15, R16
|;
(defun kdub:iniget-entrylist
(inifile section / entrylist templist entrydata returnlist)
(if (setq entrylist (acet-ini-get inifile section))
(progn (foreach key entrylist
(setq entrydata (acet-ini-get inifile section key)
entrydata (if entrydata
entrydata
""
)
templist (cons (cons key entrydata) templist)
)
)
(setq returnlist (reverse templist))
)
;; no valid entry in section
)
returnlist
)
;;;------------------------------------------------------------------
;;;------------------------------------------------------------------
;;;
;|
(KDUB:iniget-entryvalue
< inifile > : as string - fully qualified drive:\\path\\name
< section > : as string
< key >: as string
)
Returnstring shall be either :
1 ] entryvalue as string
2 ] nil if process error, no key , key has no value.
KWBrown :- Rev : 2003-Oct-17
For Acad R15, R16
|;
(defun kdub:iniget-entryvalue (inifile section key / returnstring)
(acet-ini-get inifile section key)
;; nil if not existing or empty
)
;;;------------------------------------------------------------------
;;;------------------------------------------------------------------
;;;
;|
(KDUB:iniget-entry-names
< inifile > : as string - fully qualified drive:\\path\\name
< section > : as string
)
Returnlist shall be either :
1 ] a list of entry names as strings
2 ] nil if process error or ini file has no section header or no entrys in header.
KWBrown :- Rev : 2003-Oct-17
For Acad R15, R16
|;
(defun kdub:iniget-entry-names
(inifile section / tempdata returnlist)
(acet-ini-get inifile section)
)
;;;------------------------------------------------------------------
;;;------------------------------------------------------------------
;;;
;|
(KDUB:iniget-section-names
< inifile > : as string - fully qualified drive:\\path\\name
)
Returnlist shall be either :
1 ] a list of section names as strings
2 ] nil if process error or ini file has no section headers.
KWBrown :- Rev : 2003-Oct-17
For Acad R15, R16
|;
(defun kdub:iniget-section-names (inifile / tempdata returnlist)
(acet-ini-get inifile)
)
;;;------------------------------------------------------------------
;;;------------------------------------------------------------------
;;;
;|
(KDUB:iniget-validatefilename
< inifile > : as string - file name or qualified "drive:\\path\\name" or nil
)
Return tempfile shall be either :
1 ] string qualified drive:\\path\\name.ext
2 ] nil if process error or file not found.
KWBrown :- Rev : 2003-Oct-17
For Acad R15, R16
|;
(defun kdub:iniget-validatefilename (inifile / returnstring)
(or (and inifile (setq returnstring (findfile inifile)))
(setq returnstring "")
)
(if (zerop (strlen returnstring))
(setq returnstring (getfiled "Select Configuration .INI file"
(if inifile
inifile
""
)
"INI"
0
)
)
)
(if (not returnstring)
;; invalid filefind
;; if user cancels from file selection
(acet-ui-message "Unable to process request - .INI file not found"
"File find Error --- time for a beer or three :)"
(+ 0 16)
)
)
returnstring
)
;;;------------------------------------------------------------------
;;;------------------------------------------------------------------
;;;
(princ)