Author Topic: Question of the day #7  (Read 2125 times)

0 Members and 1 Guest are viewing this topic.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Question of the day #7
« on: December 03, 2004, 12:38:31 PM »
Using getfiled, write a function that prompts the user to select a .txt file from "My Documents" and then opens that file in Notepad.


Question of the day guidelines:
1. Please do not post your answer for 24 hours after the time of the post.
2. If you wish you may post something like "I've got it!"
3. Feel free to ask questions, or for hints.
4. Feel free to PM the person who asked the question.
5. Do not be embarrassed by your answer or code.
TheSwamp.org  (serving the CAD community since 2003)

ronjonp

  • Needs a day job
  • Posts: 7531
Question of the day #7
« Reply #1 on: December 06, 2004, 11:09:08 AM »
Code: [Select]
(defun c:get (/ txt)
(setq txt (getfiled "Select a Text File" (strcat "C:/Documents and Settings/" (getenv "username") "/My Documents/") "txt" 8))
(startapp "notepad" txt)
(princ)
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Question of the day #7
« Reply #2 on: December 06, 2004, 11:15:54 AM »
Excellent ronjonp. This is what I had.
Code: [Select]

(defun c:start-new (/ file2open)
  (if
    (setq file2open
 (getfiled
   "Select text file to open"
   (strcat (getenv "USERPROFILE")"\\My Documents\\")
   "txt"
   8
   )
   )

 (startapp "notepad" file2open)
 )
    )
TheSwamp.org  (serving the CAD community since 2003)

ronjonp

  • Needs a day job
  • Posts: 7531
Question of the day #7
« Reply #3 on: December 06, 2004, 11:21:53 AM »
Userprofile.....I thought there was an easier way :).  I've used %userprofile% in batch files, but totally forgot about it.

Keep em coming Mark :D

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC