I 'm taking a string and cross-checking for a match in a comma delimited text file. The only common denominator between 1500 different strings is their "type", which is always the 2nd element in the returned list after matching the string. Some of the returned lists have (text), which throws off my nth count for those lists, but other than that they are consistent.
I have found a solution using an if statement (see below) which accounts for each situation and is consistent throughout, but I'd still like to see how to resolve the original predicament. For science purposes.
Code snippet:
(findfile (setq TextFile "mytxtfile.txt"))
(setq SearchStr (strcat "Part1" ","))
(setq Opened (open TextFile "r"))
(while (setq tmpLine (read-line Opened))
(if (vl-string-search SearchStr tmpLine)
(setq endlist tmpLine)
)
)
(close Opened)
(if (/= endlist nil)
(progn
(setq term_type1_list (read (strcat "(" (vl-string-translate "," " " endlist) ")")))
(setq term_list1_lngth (length term_type1_list))
(if (= term_list1_lngth 4)
(setq term_type1 (nth 1 term_type1_list))
(setq term_type1 (nth 2 term_type1_list))
)
)
)
AutoCad 2018 (full)
Win 11 Pro