Author Topic: What no vl-file-MAKE  (Read 2335 times)

0 Members and 1 Guest are viewing this topic.

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
What no vl-file-MAKE
« on: April 20, 2011, 02:34:24 PM »
I can find all the vl-functions for every possible condition for handling files in the developer help files but none for creating a file. 

Would (vl-filename-mktemp)  work a permanent file?  The help is waving me off with this
Quote
Calculates a unique file name to be used for a temporary file

I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: What no vl-file-MAKE
« Reply #1 on: April 20, 2011, 02:37:27 PM »
Don't mean to be flip but please define create.

vl-filename-mktemp makes a unique file name, it's up to you to create it, i.e. (setq handle (open the_temp_file_name "w")) ...
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: What no vl-file-MAKE
« Reply #2 on: April 20, 2011, 02:57:58 PM »
Here's an example of how I used vl-file-mktemp to create my drawing file, to then easily wblock to a defined temporary 'file'.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: What no vl-file-MAKE
« Reply #3 on: April 20, 2011, 03:02:18 PM »
Don't mean to be flip but please define create.

You can be flip with anytime after you bought me dinner.   :evil: :-D

But serious, I want to create a text file but a permanent file not a temporary file.  That is my concern.

vl-filename-mktemp makes a unique file name, it's up to you to create it, i.e. (setq handle (open the_temp_file_name "w")) ...

I am trying to, I am trying to.
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: What no vl-file-MAKE
« Reply #4 on: April 20, 2011, 03:03:50 PM »
Then just use the open function with a "W" argument. It creates the file to which you can 'write-line' strings.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: What no vl-file-MAKE
« Reply #5 on: April 20, 2011, 04:09:34 PM »
Then just use the open function with a "W" argument. It creates the file to which you can 'write-line' strings.
That is just it.  I do not want to write to it now.  The user will fill in the file later.  I just want an empty file. Really what I want to do is control the file name of the file so I can path to it.
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: What no vl-file-MAKE
« Reply #6 on: April 20, 2011, 04:16:52 PM »
Then just use the open function with a "W" argument. It creates the file to which you can 'write-line' strings.
That is just it.  I do not want to write to it now.  The user will fill in the file later.  I just want an empty file. Really what I want to do is control the file name of the file so I can path to it.

Code: [Select]
(defun makeTextFile (filename / f)
  (if (setq f (open filename "W"))
    (progn (close f) (findfile filename))
  )
)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

ronjonp

  • Needs a day job
  • Posts: 7529
Re: What no vl-file-MAKE
« Reply #7 on: April 20, 2011, 04:17:30 PM »
You don't have to write to the file to create it. Just use "w" like Alan suggested and then use the close function.

DOH .. too slow :-D

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: What no vl-file-MAKE
« Reply #8 on: April 20, 2011, 04:36:50 PM »
Alright I am over that hurdle but I am back at the limitation of the # of characters in the file name.

Quote
vl-filename-mktemp
Return Values

A string containing a file name, in the following format:

directory\base<XXX><.extension>
where:

base is up to 5 characters, taken from pattern

XXX is a 3-character unique combination

I need the name to be longer, much longer.   This is what I got so far.
Code: [Select]
(defun c:test ()

  (setq UserFolder1 (strcat "\\Cad Docs and Files"))
  (setq UserFolder2 (strcat "\\Customization and Support Files"))

  (setq UserPath1 (strcat MyDocPrefx UserFolder1))
  (setq UserPath2 (strcat UserPath1 UserFolder2))

  (vl-mkdir UserPath1) ; checks to see if new folder is present and if not creates it.
  (vl-mkdir UserPath2)

  (setq DictFileName (strcat UsersLogInName " SpellDict.cus"))
  (setq DictFilePath (strcat UserPath2 "\\" DictFileName))
  (setq DictFile (vl-filename-mktemp DictFilePath))

  (setq tempfile (open DictFile "w"))
  (close tempfile)

)


returns me a file name that is Ted K004.cus
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans