Author Topic: String Problem  (Read 1614 times)

0 Members and 1 Guest are viewing this topic.

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
String Problem
« on: November 21, 2008, 04:53:05 PM »
I use the following lisp to open project folders straight from a pulldown.  My problem is handling comma's in the project name.  The lisp asks for the job number, searches the Job_List.txt file for the full project folder name, then opens the folder thru explorer.  It works for the 200659 project, but not the 200768 project because of the comma in the folder name, I'm assuming.  Any thoughts?

Truncated contents of "Job_List.txt"
Code: [Select]
200659 Mini-Mart (7601 S. State Street)
200768 Merlin Mufflers & 3-Unit Retail (Mokena, IL)

Open_Job_Folder.lsp
Code: [Select]
(defun c:Open_Job_Folder (/ output file search nl tc rf tl)
(IF jobnum (SETQ search jobnum)(setq search (getstring t "\nJob Number: ")))
 
   (setq tc "No")

   (setq rf (open "Z:/Projects/Job_List.txt" "r"))
   (while (setq nl (read-line rf))
          (if (= tc "No")
              (setq tl (strcase nl)
                    search (strcase search))
              (setq tl nl))
          (if (wcmatch tl (strcat "*" search "*"))
              (setq output (cons nl output))))
   (close rf)

   (foreach n output (setq job n))
  (setq year (substr job 1 4))
  (setq job (strcat "Z:\\projects\\" year " projects\\" job "\\"))
  (startapp "explorer"  job)
  (setq jobnum nil
job nil
year nil)
  )

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: String Problem
« Reply #1 on: November 21, 2008, 07:48:55 PM »
It's the embedded spaces that STARTAPP does not like, not the comma ...

Perhaps try something like this
        (SETQ job (STRCAT "Z:\\projects\\" "\"" year " projects\\"  job "\""  "\\"))
to quote the folder name with the spaces

==>>"Z:\\projects\\\"2007 projects\\200768 Merlin Mufflers & 3-Unit Retail (Mokena, IL)\"\\"


OR
    (SETQ job (STRCAT "Z:\\projects\\" year " projects\\"  "\""  job "\""  "\\"))
==>> "Z:\\projects\\2007 projects\\\"200768 Merlin Mufflers & 3-Unit Retail (Mokena, IL)\"\\"

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Re: String Problem
« Reply #2 on: November 24, 2008, 12:32:14 PM »
(SETQ job (STRCAT "Z:\\projects\\" "\"" year " projects\\"  job "\""  "\\"))

Works perfectly!  Thank you, Kerry!