CoCreate User Forum

CoCreate User Forum (https://www.cocreateusers.org/forum/index.php)
-   Customization (https://www.cocreateusers.org/forum/forumdisplay.php?f=12)
-   -   function that me controls the existence a file (https://www.cocreateusers.org/forum/showthread.php?t=5443)

andrea 04-01-2005 01:22 AM

function that me controls the existence a file
 
It exists in me10 a function that me controls the existence of a direttory or a file and in case I does not exist creates?

Sorry for my English bad.

clausb 04-01-2005 03:33 AM

Re: function that me controls the existence a file
 
Check out your LISP manual. For files, the LISP open function does what you want - see http://www.lisp.org/HyperSpec/Body/fun_open.html. For example:
Code:

  (setf s (open "foobar" :direction :output :if-does-not-exist :create))
For directories, either use LISP's directory command, or one of the file/directory handling functions documented in the Developer's Kit.

Claus

andrea 04-01-2005 03:35 AM

Re: function that me controls the existence a file
 
For macro in to ME10 ???????

clausb 04-01-2005 05:39 AM

Re: function that me controls the existence a file
 
Oops - sorry. I should be reading those posts more carefully 8-( :(

I don't know too much about OSDD's macro language, but the CREATE_DIRECTORY command might do what you need for directories. If the directory doesn't exist already, it will create it, otherwise issue an error (which you can probably catch using TRAP_ERROR).

For files, OPEN_OUTFILE with option DEL_OLD might do the trick.

Sorry again for the misunderstanding.

Claus

John Scheffel 04-01-2005 01:24 PM

Re: function that me controls the existence a file
 
There may be a better way, but some of our macros use logic like this to test for the existence of a file.
Code:

LET Test_file_name 'C:\my_file.txt'
TRAP_ERROR
OPEN_INFILE 1 Test_file_name END
IF (CHECK_ERROR) {file does not exist}
  OPEN_OUTFILE 1 Test_file_name
  Commands...
ELSE {file exists}
  CLOSE_FILE 1
  Commands...
END_IF


andrea 04-03-2005 10:34 PM

Re: function that me controls the existence a file
 
thank you very much!

Shaba 04-02-2018 12:15 AM

Re: function that me controls the existence a file
 
Good also for me!


All times are GMT -8. The time now is 11:57 PM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.