CoCreate User Forum  

Go Back   CoCreate User Forum > Support > Customization
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1  
Old 09-07-2006, 04:13 AM
Gary L. Gary L. is offline
Registered User
 
Join Date: Oct 2002
Location: Rockford, IL
Posts: 130
LISP Command -- Copy File

In a lisp program I have the following line to copy a file to a new name in the same folder. It doesn't work. What is the correct format?

(sd-sys-exec "cp C:/tmp/profilexy_restart C:/tmp/profilexy_restart2")

Thanks, Gary
Reply With Quote
  #2  
Old 09-07-2006, 05:13 AM
clausb's Avatar
clausb clausb is offline
Registered User
 
Join Date: Nov 2002
Posts: 1,168
Re: LISP Command -- Copy File

"cp" is UNIXese - you probably have Cygwin or some other UNIX toolset installed on your system, and want to execute them via sd-sys-exec.

sd-sys-exec will always execute the specified command via cmd.exe, i.e. any syntax that works in a DOS shell window, will also work in sd-sys-exec. "cp.exe" may not, depending on whether "cp.exe" is in a directory that is listed in PATH.

Anyway, the DOS equivalent of "cp" is "copy", and it's just as simple to use as "cp.exe". But then, you don't need to go through any of this platform-dependency mess. Here's a MUCH better approach:
Code:
  (oli:sd-copy-file "C:/tmp/profilexy_restart" "C:/tmp/profilexy_restart2")
See the IKIT documentation for details.

Claus
__________________
CoCreate Modeling FAQ: http://www.clausbrod.de/CoCreateModeling/
Reply With Quote
  #3  
Old 09-04-2007, 02:06 AM
ukawa's Avatar
ukawa ukawa is offline
Registered User
 
Join Date: Apr 2004
Location: Italy
Posts: 73
Re: LISP Command -- Copy File

Hi
I have a similar question about this thread:
I need to delete a temporary file made by my lisp: the file name is "C:\temp\1.mi"

"sd-delete-file" doesn't exists, so I think I have to use:
Code:
(oli:sd-sys-exec "del C:\temp\1.mi")
But it doesn't works and I don't understand why (in DOS shell "del C:\temp\1.mi" works).
Can I have some help, please?

Thanks in advance
Ukawa
Reply With Quote
  #4  
Old 09-04-2007, 05:42 AM
Andy Poulsen Andy Poulsen is offline
Administrator
 
Join Date: Apr 2003
Location: Fort Collins, Colorado
Posts: 273
Re: LISP Command -- Copy File

Quote:
Originally Posted by ukawa View Post
Hi
I have a similar question about this thread:
I need to delete a temporary file made by my lisp: the file name is "C:\temp\1.mi"

"sd-delete-file" doesn't exists, so I think I have to use:
Code:
(oli:sd-sys-exec "del C:\temp\1.mi")
But it doesn't works and I don't understand why (in DOS shell "del C:\temp\1.mi" works).
The main reason it isn't working is that the backslash character "\" is used in lisp to "escape" characters, which allows you to use special characters inside your text strings. Using the backslash basically tells the lisp interpreter to treat the character following the backslash as a regular character and not anything special.

In your particular case above, the lisp interpreter reads the characters following the backslashes as regular characters (which they are, in this case). So "del c:\temp\1.mi" gets changed by the lisp interpreter to "del c:temp1.mi" -- does this make sense? To include the backslashes in the string, you need to "escape" the backslashes themselves i.e. we need to use *two* of them! so using "del c:\\temp\\1.mi" should work for you.

And while sd-delete-file does not exist, there is a standard lisp function delete-file that should do what you need. If you're going to use it, you need to put the filename in quotes, and if you're going to use backslashes, you will again need to escape them. However, using forward slashes will work nicely (and is usually more convenient as well). I always prefer using forward-slash notation. So
Code:
(delete-file "c:/temp/1.mi")

or

(delete-file "c:\\temp\\1.mi")
should work for you.

I hope this makes sense...

Good luck!

andy
__________________
Andy Poulsen
AI MAXTools: Dream. Design. Done. It's that easy!
Add-ins bringing new functionality and speed to Creo Elements/Direct and CoCreate products. Now available for v17-v20+!
See them in action at www.ai-maxtools.com and then try them for yourself -- FREE!
Reply With Quote
  #5  
Old 09-04-2007, 07:27 AM
ukawa's Avatar
ukawa ukawa is offline
Registered User
 
Join Date: Apr 2004
Location: Italy
Posts: 73
Re: LISP Command -- Copy File

Wow, thanks for the quick responses, your explanation is extremely clear and useful.
Both the solutions work perfectly.
Once again, I forgot we have modeling lisp language, AS WELL AS standard lisp language.

However, thanks so much, I have really appreciated your help.
Best Regards
Ukawa
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 07:23 AM.



Hosted by SureServer    Forums   Modeling FAQ   Macro Site   Vendor/Contractors   Software Resellers   CoCreate   Gallery   Home   Board Members   Regional User Groups  By-Laws  

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
You Rated this Thread: